jQueryでスクロール位置を取得・設定する
code:javascript
$(dom).scrollTop(); // スクロール位置のGetter
$(dom).scrollTop(100); // スクロール位置のSetter
code:javascript
$(targetContainer).on('touchstart', function (event) {
if (!self.isBrowserScrollable) return;
if (getOSData() == 'iOS') return; // for iOS Browser Scroll
event = event.originalEvent;
self.touchPositionStartY = event.changedTouches0.pageY; self.scrollTopStartY = $('#contents').scrollTop();
self.isScrolling = true;
});
$(targetContainer).on('touchmove', function (event) {
KitaroLogger.log('BrowserScroll:onTouchMove');
event = event.originalEvent;
if (!self.isBrowserScrollable) event.preventDefault(); // for iOS Browser Scroll
if (!self.isBrowserScrollable) return;
if (!self.isScrolling) return;
var currentY = event.changedTouches0.pageY; var distance = currentY - self.touchPositionStartY;
var scrollTarget = $('#contents');
scrollTarget.scrollTop(self.scrollTopStartY - distance);
});
$(targetContainer).on('touchend', function (event) {
KitaroLogger.log('BrowserScroll:onTouchEnd');
self.isScrolling = false;
});