EasyUI Forum
May 15, 2024, 11:15:23 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: autoscroll panel  (Read 9988 times)
JeroenNL
Newbie
*
Posts: 37


View Profile
« on: September 25, 2015, 03:42:18 AM »

Hi,

I have a panel with a button on the top, some elements in the middle and an invisible table at the bottom. When I click the button, the table becomes visible. I want the panel to scroll down automatically to the table when I press the button. I have tried the jquery animate and scrollTo functions but can't get it to work within a JEasyUI panel...

How to achieve this effect?

Cheers,
JeroenNL
« Last Edit: September 25, 2015, 07:26:32 AM by JeroenNL » Logged
jarry
Administrator
Hero Member
*****
Posts: 2264


View Profile Email
« Reply #1 on: September 25, 2015, 05:20:49 PM »

If you are using 'scrollTo' plugin, please try:
Code:
$('#panel').scrollTo('#table', 500);

You also can extend a 'scrollTo' method for the panel to achieve this functionality.
Code:
$.extend($.fn.panel.methods, {
scrollTo: function(jq, param){
return jq.each(function(){
param.duration = param.duration || 0;
var top1 = $(param.target).offset().top;
var top2 = $(this).offset().top;
var top = $(this).scrollTop()+(top1-top2);
$(this).animate({scrollTop:top}, param.duration);
})
}
})
You can call 'scrollTo' method now.
Code:
$('#panel').panel('scrollTo', {
  target: '#table',
  duration: 400
});
Logged
JeroenNL
Newbie
*
Posts: 37


View Profile
« Reply #2 on: September 26, 2015, 04:03:26 AM »

I'm using the scrollTo from https://github.com/flesler/jquery.scrollTo but can't get it to work. Are you sure it works with a JeasyUI panel?
Logged
jarry
Administrator
Hero Member
*****
Posts: 2264


View Profile Email
« Reply #3 on: September 26, 2015, 04:28:35 AM »

Yes, it works fine. Please refer to http://jsfiddle.net/nsgcoeqo/
Logged
JeroenNL
Newbie
*
Posts: 37


View Profile
« Reply #4 on: September 26, 2015, 04:51:35 AM »

I was hoping you'd supply a jsfiddle, and you did. Thanks! Smiley

I have been testing with a panel in my app too and it works with one panel, but not with another.

That other panel has a panel-noscroll css class applied to it. Seems that's the issue, but I don't know how to solve it yet. Any ideas?

Edit: solved it by wrapping things in another panel. Now it works just fine. Thanks! Smiley
« Last Edit: September 26, 2015, 05:23:34 AM by JeroenNL » Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!