﻿/**
enyo.TranslateScrollStrategy is a helper kind that extends <a href="#enyo.TouchScrollStrategy">enyo.TouchScrollStrategy</a> 
to be optimized for scrolling environments in which effecting scroll changes with transform is fastest.

enyo.TranslateScrollStrategy is not typically created in application code.
*/
enyo.kind({
	name: "enyo.TranslateScrollStrategy",
	kind: "TouchScrollStrategy",
	clientClasses: "enyo-composite",
	components: [
		{name: "clientContainer", classes: "enyo-touch-scroller", attributes: {"onscroll": enyo.bubbler}, components: [
			{name: "client"}
		]}
	],
	calcScrollNode: function() {
		return this.$.clientContainer.hasNode();
		//return this.container.hasNode();
	},
	maxHeightChanged: function() {
		this.inherited(arguments);
		this.$.clientContainer.addRemoveClass("enyo-fit", !this.maxHeight);
	},
	shouldDrag: function(inSender, inEvent) {
		// stop and update drag info before checking drag status
		this.stop();
		this.calcStartInfo();
		return this.inherited(arguments);
	},
	scrollMathStart: function(inSender) {
		this.inherited(arguments);
		if (this.scrollNode) {
			this.startX = this.getScrollLeft();
			this.startY = this.getScrollTop();
		}
	},
	scrollMathScroll: function(inSender) {
		this.scrollLeft = -inSender.x;
		this.scrollTop = -inSender.y;
		// hmph, scroll called after stop
		if (this.isScrolling()) {
			this.effectScroll(this.startX - this.scrollLeft, this.startY - this.scrollTop);
		}
		if (this.thumb) {
			this.updateThumbs();
		}
		this.doScroll(inSender);
	},
	// while moving, scroller uses translate
	effectScroll: function(inX, inY) {
		var o = inX + "px, " + inY + "px, 0";
		this.effectTransform({translate3d: o});
	},
	// when stopped, we use scrollLeft/Top (makes cursor positioning automagic)
	effectScrollStop: function() {
		this.effectTransform({translate3d: "0, 0, 0"});
		this.setScrollLeft(this.scrollLeft);
		this.setScrollTop(this.scrollTop);
	},
	down: enyo.nop
});

@@ -941,14 +941,63 @@
 his.
-stop()
+dragStop = true;%0A%09%09this.stop();%0A%09%09this.dragStop = false
 ;%0A%09%09
@@ -1489,19 +1489,16 @@
 lTop);%0A%09
-%09%7D%0A
 %09%09if (th
@@ -1505,24 +1505,25 @@
 is.thumb) %7B%0A
+%09
 %09%09%09this.upda
@@ -1530,24 +1530,29 @@
 teThumbs();%0A
+%09%09%09%7D%0A
 %09%09%7D%0A%09%09this.d
@@ -1570,24 +1570,191 @@
 ender);%0A%09%7D,%0A
+%09scrollMathStop: function(inSender) %7B%0A%09%09this.effectScrollStop();%0A%09%09if (this.thumb && !this.dragStop) %7B%0A%09%09%09this.hideThumbs(100);%0A%09%09%7D%0A%09%09this.doScrollStop(inSender);%0A%09%7D,%0A
 %09// while mo

fix scroll thumb disappearing early when scrolling while thumb is showing