From 5c770b772179cc2c3a0455f67025978b44e4b547 Mon Sep 17 00:00:00 2001 From: Armen Kesablyan Date: Wed, 20 Jun 2012 13:06:11 -0700 Subject: binding-hud Scroll Up Signed-off-by: Armen Kesablyan --- .../binding-hud.reel/binding-hud.js | 68 +++++++++++++--------- js/stage/binding-view.reel/binding-view.js | 2 +- 2 files changed, 41 insertions(+), 29 deletions(-) diff --git a/js/stage/binding-view.reel/binding-hud.reel/binding-hud.js b/js/stage/binding-view.reel/binding-hud.reel/binding-hud.js index 4b40d4da..0893e8d8 100755 --- a/js/stage/binding-view.reel/binding-hud.reel/binding-hud.js +++ b/js/stage/binding-view.reel/binding-hud.reel/binding-hud.js @@ -175,42 +175,54 @@ exports.BindingHud = Montage.create(Component, { }, isOverScroller: { - value: function(mousePoint) { + value: function(e) { if(this.scrollSpace < this.properties.length) { - if (this.scrollInterval === null) { - var newX = mousePoint.x - this.x; - var newY = mousePoint.y - this.y; - var scrollUpStartX = 5; - var scrollUpEndX = scrollUpStartX + this.titleElement.offsetWidth; - var scrollUpStartY = this.titleElement.offsetHeight; - var scrollUpEndY = scrollUpStartY + this.scrollUp.offsetHeight; - - var scrollDownStartX = 5; - var scrollDownEndX = scrollUpStartX + this.titleElement.offsetWidth; - var scrollDownStartY = scrollUpEndY + this.optionsRepeater.element.offsetHeight; - //scrollDownEndy to small find out y; - var scrollDownEndY = scrollUpEndY + this.scrollDown.offsetHeight; - console.log(scrollDownStartX,scrollDownEndX, scrollDownStartY, scrollDownEndY, newX, newY ); - if(scrollDownStartX < newX && (scrollDownEndX) > newX) { - if(scrollDownStartY < newY && (scrollDownEndY) > newY) { - debugger; - } + var isOverScroller = false; + var mousePoint = webkitConvertPointFromPageToNode(this.element, new WebKitPoint(e.pageX, e.pageY)); + + var scrollUpStartX = 5; + var scrollUpEndX = scrollUpStartX + this.titleElement.offsetWidth; + var scrollUpStartY = this.titleElement.offsetHeight; + var scrollUpEndY = scrollUpStartY + this.scrollUp.offsetHeight; + if(scrollUpStartX < mousePoint.x && (scrollUpEndX) > mousePoint.x) { + if(scrollUpStartY < mousePoint.y && (scrollUpEndY) > mousePoint.y) { + this.handleScroll("up"); + isOverScroller = true; } } + + var scrollDownStartX = 5; + var scrollDownEndX = scrollDownStartX + this.titleElement.offsetWidth; + var scrollDownStartY = scrollUpEndY + this.optionsRepeater.element.offsetHeight; + var scrollDownEndY = scrollDownStartY + this.scrollDown.offsetHeight; + + if(scrollDownStartX < mousePoint.x && (scrollDownEndX) > mousePoint.x) { + if(scrollDownStartY < mousePoint.y && (scrollDownEndY) > mousePoint.y) { + this.handleScroll("down"); + isOverScroller = true; + } + } + + if(!isOverScroller) { + clearInterval(this.scrollInterval); + this.scrollInterval = null; + } } } }, handleScroll: { value: function(direction) { - if(direction === "down") { - this.scrollInterval = setInterval(function() { - self.optionsRepeater.element.scrollTop += 18; - }, 200); - } else { - this.scrollInterval = setInterval(function() { - self.optionsRepeater.element.scrollTop -= 18; - }, 200); + if (this.scrollInterval === null) { + if(direction === "down") { + this.scrollInterval = setInterval(function() { + this.optionsRepeater.element.scrollTop += 3; + }.bind(this), 50); + } else { + this.scrollInterval = setInterval(function() { + this.optionsRepeater.element.scrollTop -= 3; + }.bind(this), 50); + } } } }, @@ -232,7 +244,7 @@ exports.BindingHud = Montage.create(Component, { } } } - this.needsDraw = true; + //this.needsDraw = true; } }, diff --git a/js/stage/binding-view.reel/binding-view.js b/js/stage/binding-view.reel/binding-view.js index 9bd99176..1d5ef4db 100755 --- a/js/stage/binding-view.reel/binding-view.js +++ b/js/stage/binding-view.reel/binding-view.js @@ -281,7 +281,7 @@ exports.BindingView = Montage.create(Component, { if(obj.y < mousePoint.y && (obj.y + obj.element.offsetHeight) > mousePoint.y) { overHud = true; if(this._isDrawingConnection) { - obj.isOverScroller(mousePoint); + obj.isOverScroller(e); } } } -- cgit v1.2.3