语言

Menu
Sites
Language
Listening For Scroll Event

Hello,

I'm trying to listen for a scrolling event to do some things on a page. The code below works fine on a web page, but doesn't work on the device. Having trouble finding the answer to this problem. Thanks ahead of time:

 

var a = document.getElementById('flightDetails'),
	btn = document.getElementById('flightDetailsBtn');

a.onscroll = function() {
   btn.style.bottom = "0";
};

a.addEventListener('scrollstart', function(e) {
   alert('working');
   alert(e);
});

 

Thanks ahead of time.

响应

6 回复
Vikram

Hi,

Can you show the full code in order to finding the problem easier.

Casey Baggz

Hey Vikram,

Can you check out the conversation with Colin and see if you maybe have some better insight on this?

Thanks!

Casey Baggz

I basically want to do this: http://codepen.io/caseybaggz/pen/Vvwpjr?editors=011

colin Rao

Hi,

Possible it's compatibility issue.

Try as below, you can change the target "window" to any other html element.

$( window ).scroll(function() {
  // do action here
});

or,

$(document).on("scrollstart",function(){
  alert("scrollstart!");
});

$(document).on("scrollstop",function(){
  alert("scrollstop!");
});

// document can be changed to other html element.

 

Casey Baggz

Hi Colin,

Regarding swiping left & right, scrollstart  works great. But, unfortunately, for swiping vertically down a page (which is what I need), it doesn't work at all.

Likewise, .scroll() works great on the web...but not within a Tizen app on the device itself. I just need a way to recognize the event when a user scrolls down a page (literally, EXACTLY what .scroll() does for the web. Not sure why it doesn't work within Tizen???).

 

I'm using 2.3.1_r23 for the S2

 

Thanks for your help and time once again.

 

 

 

AVSukhov

Hello,

You can find info about Scroll Handler in documentation:

https://developer.tizen.org/dev-guide/2.3.0/org.tizen.web.apireference/html/ui_fw_api/mobile/ns_widget_mobile_ScrollHandler.htm