mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 10:37:34 +00:00
loading graphic layers works with right order
This commit is contained in:
parent
522b5092f5
commit
9c9db8ca8c
6 changed files with 132 additions and 33 deletions
|
|
@ -22,7 +22,11 @@ function (Nc, Exception, Layer) {
|
|||
];
|
||||
}
|
||||
|
||||
LayerManager.prototype.createAndInsert = function(id, parallaxSpeed, referenceId, behind) {
|
||||
/*
|
||||
* If no referenceId is given, the layer is inserted in the far background (behind=true)
|
||||
* or in the foreground (behind=false/null)
|
||||
*/
|
||||
LayerManager.prototype.createAndInsert = function(id, parallaxSpeed, behind, referenceId) {
|
||||
|
||||
var referenceIndex = -1;
|
||||
behind = !!behind;
|
||||
|
|
@ -44,11 +48,13 @@ function (Nc, Exception, Layer) {
|
|||
}
|
||||
|
||||
var layer = new Layer(id, parallaxSpeed);
|
||||
var layerIndex = behind ? referenceIndex -1 : referenceIndex;
|
||||
var layerIndex = behind ? referenceIndex : referenceIndex + 1;
|
||||
|
||||
this.layers.splice(layerIndex, 0, layer);
|
||||
|
||||
this.rearrangeLayers();
|
||||
|
||||
console.log(this.layers.map(function(o) {return o.name}))
|
||||
};
|
||||
|
||||
LayerManager.prototype.rearrangeLayers = function() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue