EasyUI Forum
May 10, 2024, 01:50:47 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Animation in combo and datetime picker.  (Read 8608 times)
A-K
Full Member
***
Posts: 122


View Profile WWW
« on: July 19, 2014, 07:46:07 AM »

Hey, I would like to add animation(like fade or slide effects) to the combobox/combotree/combogrid when the panel is opened and closed and the same to the panel of the
datetime picker. I have searched the forums and the documentations but could not find any help for this.

Please any help would be very appreciated!

Alon.
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: July 19, 2014, 05:24:10 PM »

Please override the $.fn.combo.method.showPanel method to achieve this functionality.
Code:
(function($){
  var showPanel = $.fn.combo.methods.showPanel;
  $.fn.combo.methods.showPanel = function(jq){
    return jq.each(function(){
      var opts = $(this).combo('options');
      var p = $(this).combo('panel');
      $.extend(p.panel('options'), {
        onBeforeOpen: function(){
          $(this).panel('panel').css('z-index', $.fn.menu.defaults.zIndex++);
          show($(this), opts.animate, opts.speed);
          return false;
        },
        onBeforeClose: function(){
          hide($(this), opts.animate, opts.speed);
          return false;
        }
      });
      showPanel.call($.fn.combo.methods, $(this));
      function show(p, type, speed){
        type = type || 'show';
        speed = speed || 0;
        var p = p.panel('panel');
        switch(type){
          case 'show':
            p.show(speed);
            break;
          case 'slide':
            p.slideDown(speed);
            break;
          case 'fade':
            p.fadeIn(speed);
            break;
        }
      }
      function hide(p, type, speed){
        type = type || 'show';
        speed = speed || 0;
        var p = p.panel('panel');
        switch(type){
          case 'show':
            p.hide(speed);
            break;
          case 'slide':
            p.slideUp(speed);
            break;
          case 'fade':
            p.fadeOut(speed);
            break;
        }
      }
    })
  }
})(jQuery);

Set 'animate' and 'speed' properties for your combo components to define animate effects.
Code:
<input class="easyui-datebox" data-options="animate:'fade',speed:600,...">
<input class="easyui-combbox" data-options="animate:'slide',speed:600,...">
Logged
A-K
Full Member
***
Posts: 122


View Profile WWW
« Reply #2 on: July 20, 2014, 12:02:14 PM »

Thanks for the quick answer!
Another question, Is it possible to create the effect like the datebox in win 7? I mean
when you press on the month it zooms out nicely before it shows all the days in that month and also zooms in when you select a month.

https://imageshack.com/i/ez81edf2p

Thanks, Alon.
« Last Edit: July 20, 2014, 12:04:31 PM by AlonKatz » 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!