1. JavaScript / Говнокод #12830

    +152

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    function TimeViewport(rootElement, container, canvas, minZoom, maxZoom)
    {
    	this.container = container;
    	this.rootElement = rootElement;
    	this.lowPassAlpha = 0.38;
    	this.canvas = canvas;
    	this.minZoom = minZoom;
    	this.maxZoom = maxZoom;
    	this.zoom = minZoom;
    	this.size = Math.min(1.0, 1.0 / Math.pow(2, this.zoom));
    	this.left = 0.5 - this.size / 2.0;
    	this.right = 0.5 + this.size / 2.0;
    	this.mouse = {
    		isDown : false,
    		panning : false,
    		velocityMode : false,
    		downPos : {x : 0, y : 0}, 
    		movePos : {x : 0, y : 0},
    		lastMovePos : {x : 0, y : 0}
    	};
    	var self = this;
    	this.filtered = {
    		"left" : 0.5 - self.size / 4.0,
    		"right" : 0.5 + self.size / 4.0
    	};
    	this.lastRedrawTime = (new Date()).getTime();
    	this.maxRedrawInterval = 500;
    	setInterval(function () { if (self.doLowPass != null) self.doLowPass(); }, 17);
    	this.canvas.onmousedown = function(event) { self.mouseDown(event) };
    	this.canvas.onmousewheel = function(event) { self.onMouseWheel(event); };
    	var oldMouseMoveHandler = this.rootElement.onmousemove;
    	this.rootElement.onmousemove = function (event) {
    		if (self.mouseMove) self.mouseMove(event);
    		if (oldMouseMoveHandler != null) oldMouseMoveHandler(event);
    	};
    	var oldMouseUpHandler = this.rootElement.onmouseup;
    	this.rootElement.onmouseup = function (event) {
    		if (self.mouseUp) self.mouseUp(event);
    		if (oldMouseUpHandler != null) oldMouseUpHandler(event);
    	};
    	var oldMouseLeaveHandler = this.rootElement.onmouseleave;
    	this.rootElement.onmouseleave = function (event) {
    		if (self.mouseLeave) self.mouseLeave(event);
    		if (oldMouseLeaveHandler != null) oldMouseLeaveHandler(event);
    	};
    };

    Очередной велосипедик.

    Запостил: just_nameless, 30 Марта 2013

    Комментарии (5) RSS

    Добавить комментарий