shshaw / canvallax Goto Github PK
View Code? Open in Web Editor NEWEasy parallax effects and element management on canvas.
Home Page: http://shshaw.github.io/Canvallax/
Easy parallax effects and element management on canvas.
Home Page: http://shshaw.github.io/Canvallax/
Thank you for your work, I really liked it and have included it on the site.
http://vvl99.narod.ru/Clouds.html
If you reload the page, the code from Canvallax v.1 and Canvallax v.2 will be used randomly:
if (type) { ctx.translate(randomRange(halfw, width - (w * maxScale * 1.3)), randomRange(halfh + halfh / 4, height - (h * maxScale))) } else { ctx.translate( weightedRandom( width - (w * randScale), 5 ), weightedRandom( height- (h * randScale), 5) ) };
Which corresponds to:
location.hash = type ? "puffy_clouds" : "cumulus_clouds";
Snippet for using spritesheets with Canvallax
(function(win){
win._clx = win._clx || [];
win._clx.push(function(canvallax){
'use strict';
var _originalDraw = canvallax.Image.fn.draw;
canvallax.Image.fn.draw = function(ctx,coords){
if ( this.sprite && this.image ) {
ctx.drawImage(this.image, this.sprite[0], this.sprite[1], this.width, this.height, coords[0], coords[1], this.width, this.height);
} else {
_originalDraw.apply(this,arguments);
}
};
});
})(this);
var spriteSheet = canvallax.Image({ src: './spritesheet.png' });
var sprite = spriteSheet.clone({ sprite: [frame.x, frame.y, frame.width, frame.height] });
I took the example shown in codepen: http://codepen.io/shshaw/pen/ZbExyV
and I get an error: Canvallax.js:80 Uncaught TypeError: Cannot read property 'scrollLeft' of null
Looks like the line body = doc.body
gets a null
since doc.body
is null
without changing anything, just copying the example from there and it is not working.
my html
looks like that (I omitted the html
and head
tags):
<body>
<script>
var can = Canvallax({
className: 'bg-canvas',
damping: 40
});
/* then the //Clouds part and the rest of the Canvallax example */
</script>
</body>
It doesn't even get to the clouds part... What am I missing??
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.