|
@@ -26,8 +26,8 @@
|
|
|
var _ctx = _canvas.getContext('2d');
|
|
|
var _dpi = window.devicePixelRatio;
|
|
|
var _scene_props = {
|
|
|
- width:0,
|
|
|
- height:0,
|
|
|
+ width:window.innerWidth,
|
|
|
+ height:window.innerHeight,
|
|
|
// 'margin_top':90, // with red border on head
|
|
|
'margin_top':75, // without red border on head
|
|
|
// 'margin_top':0,
|
|
@@ -36,6 +36,12 @@
|
|
|
// 'margin_bottom':0,
|
|
|
'margin_left':0
|
|
|
};
|
|
|
+ var _evolution_zone = {
|
|
|
+ left:_scene_props.width/4,
|
|
|
+ right:_scene_props.width - _scene_props.width/4,
|
|
|
+ center:_scene_props.width/2,
|
|
|
+ };
|
|
|
+
|
|
|
var _physics = new Physics();
|
|
|
var _nodes = [];
|
|
|
var _articles_nodes = [];
|
|
@@ -102,12 +108,15 @@
|
|
|
_canvas.height = _scene_props.height*_dpi;
|
|
|
_ctx.scale(_dpi, _dpi);
|
|
|
|
|
|
+ moveEvolutionZone();
|
|
|
+
|
|
|
if(_loaded){
|
|
|
for (var i = 0; i < _nodes.length; i++) {
|
|
|
_nodes[i].onResizeCanvas();
|
|
|
}
|
|
|
// move _attracter and _repulser to their right places again
|
|
|
- resizePhysics();
|
|
|
+ // moveEvolutionZone() will trigger resizePhysics()
|
|
|
+ // resizePhysics();
|
|
|
}
|
|
|
|
|
|
};
|
|
@@ -161,7 +170,9 @@
|
|
|
};
|
|
|
function resizePhysics(){
|
|
|
// attracters
|
|
|
- _attracter.position = {x:_scene_props.width/2, y:_scene_props.height/2};
|
|
|
+ if(typeof _attracter != 'undefined'){
|
|
|
+ _attracter.position = {x:_evolution_zone.center, y:_scene_props.height/2};
|
|
|
+ }
|
|
|
};
|
|
|
|
|
|
// _ _ _
|
|
@@ -479,7 +490,10 @@
|
|
|
this.p.velocity.multiplyScalar(0.99); // 0.995
|
|
|
}
|
|
|
}
|
|
|
- if( Math.abs(_attracter.position.x - this.x) > _scene_props.width/4
|
|
|
+ // limit evolution zone
|
|
|
+ // if( Math.abs(_attracter.position.x - this.x) > _scene_props.width/4
|
|
|
+ // || Math.abs(_attracter.position.y - this.y) > _scene_props.height/4){
|
|
|
+ if( this.x < _evolution_zone.left || this.x > _evolution_zone.right
|
|
|
|| Math.abs(_attracter.position.y - this.y) > _scene_props.height/4){
|
|
|
this.attract.on = true;
|
|
|
}else{
|
|
@@ -731,6 +745,23 @@
|
|
|
// console.log('_physics.attractions.length', _physics.attractions.length);
|
|
|
};
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ // ___ _ _ _ ____
|
|
|
+ // | __|_ _____| |_ _| |_(_)___ _ _ |_ /___ _ _ ___
|
|
|
+ // | _|\ V / _ \ | || | _| / _ \ ' \ / // _ \ ' \/ -_)
|
|
|
+ // |___|\_/\___/_|\_,_|\__|_\___/_||_| /___\___/_||_\___|
|
|
|
+ function moveEvolutionZone(l, r){
|
|
|
+ var left = l || 0;
|
|
|
+ var right = r || 0;
|
|
|
+ _evolution_zone.left = Math.max(_scene_props.width/5, left+20);
|
|
|
+ _evolution_zone.right = Math.min(_scene_props.width - _scene_props.width/5, _scene_props.width-right+20);
|
|
|
+ _evolution_zone.center = _evolution_zone.left + (_evolution_zone.right - _evolution_zone.left)/2;
|
|
|
+ // move _attracter to the center of the zone
|
|
|
+ resizePhysics();
|
|
|
+ }
|
|
|
+
|
|
|
// ___ _ ___ _ _ _ _
|
|
|
// | _ \__ _ _ _ __| |___ _ __ | _ \ |__ _ _ _| (_)__| |_
|
|
|
// | / _` | ' \/ _` / _ \ ' \ | _/ / _` | || | | (_-< _|
|
|
@@ -1050,6 +1081,10 @@
|
|
|
.parents('.item-list').removeClass('opened');
|
|
|
scrambleCollection();
|
|
|
}
|
|
|
+ })
|
|
|
+ .on('visible-space-changed', function(e){
|
|
|
+ // limits are absolute distance from each side (not positions from left)
|
|
|
+ moveEvolutionZone(e.left_limit, e.right_limit);
|
|
|
});
|
|
|
};
|
|
|
|