Uploaded image for project: 'ZK'
  1. ZK
  2. ZK-3789

Animation onRestore cause redrawn in CKEditor

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • 8.5.1
    • 8.5.0
    • None
    • Security Level: Jimmy
    • None
    • ZK 8.5.1 S1
    • None

      Steps to Reproduce

      Run fiddle
      http://zkfiddle.org/sample/1p1a2uh/2-bandbox-popup-redraw-ckeditor

      Open bandbox popup

      Current Result

      The onRestore zWatch event cause Ckeditor to redraw

      Expected Result

      Ckeditor shouldn't redraw

      Debug Info

      onRestore called by animation js:
      https://github.com/zkoss/zk/commit/4bd5380529a8262d3f616fe487b7acd8eff3afd0#diff-e5834475b1ace13862f7fe5936889e61

      Root Cause

      following ZK 3695

      Workaround

      <script>
              zk.afterLoad('zk', function() {
                  console.log('afterload zk');
      
              	var _aftAnims = [], //used zk.afterAnimate
                  _jqstop = jq.fx.stop;
      
                  jq.fx.stop = function () {
                      _jqstop();
                      for (var fn; fn = _aftAnims.shift();)
                          fn();
                  };
      
                  function _addAnique(id, data) {
                      var ary = zk._anique[id];
                      if (!ary)
                          ary = zk._anique[id] = [];
                      ary.push(data);
                  }
                  function _doAnique(id) {
                      var ary = zk._anique[id];
                      if (ary) {
                          var al = ary.length;
                          while (al) {
                              var data = ary.shift();
                              if (jq(data.el).is(':animated')) {
                                  ary.unshift(data);
                                  break;
                              }
                              zk(data.el)[data.anima](data.wgt, data.opts);
                              al--;
                          }
      
                          if (!al)
                              delete zk._anique[id];
                      }
                  }
      
                  function _saveProp(self, set) {
                      var ele = self.jq;
                      for (var i = set.length; i--;)
                          if (set[i] !== null) ele.data('zk.cache.' + set[i], ele[0].style[set[i]]);
                      return self;
                  }
                  function _restoreProp(self, set) {
                      var ele = self.jq;
                      for (var i = set.length; i--;)
                          if (set[i] !== null) ele.css(set[i], ele.data('zk.cache.' + set[i]));
                      return self;
                  }
                  function _checkAnimated(self, wgt, opts, anima) {
                      if (self.jq.is(':animated')) {
                          _addAnique(wgt.uuid, {el: self.jq[0], wgt: wgt, opts: opts, anima: anima});
                          return true;
                      }
                      return false;
                  }
                  function _checkPosition(self, css) {
                      var pos = self.jq.css('position');
                      if (!pos || pos == 'static')
                          css.position = 'relative';
                      return self;
                  }
      
      
      
                  var _xDZjq = {};
                      zk.override(zjq.prototype, _xDZjq, {
                       defaultAnimaOpts: function (wgt, opts, prop, visible) {
                          var self = this;
                          jq.timers.push(function () {
                              if (!visible)
                                  zWatch.fireDown('onHide', wgt);
                              if (opts.beforeAnima)
                                  opts.beforeAnima.call(wgt, self);
                          });
      
                          var aftfn = opts.afterAnima;
                          opts.afterAnima = function () {
                              self._removeWrapper(self.jq);
                              if (prop) _restoreProp(self, prop);
                              if (visible) {
                                  /*
                                   * fixed a bug of the finished animation for IE
                                   * refix for ZK-568: Open combobox then select last item. reopen combobox then you should see selected item without scroll
                                   */
                                  var zkie = zk.ie;
                                  if (zkie || zk.edge || zk.safari) {
                                      // refine ZK-3695: fire down onRestore after the wrapper was removed
                                      zWatch.fireDown('onRestore', wgt);
                                      if (zkie == 8 || zkie == 10) zk(self.jq[0]).redoCSS();
                                  }
                                  zUtl.fireShown(wgt);
                              } else {
                                  self.jq.hide();
                              }
                              if (aftfn) aftfn.call(wgt, self.jq.context);
                              wgt.afterAnima_(visible);
                              setTimeout(function () {
                                  _doAnique(wgt.uuid);
                              });
                          };
                          return this;
                      }
                      });
                  });
      
          </script>
      

            bobpeng bobpeng
            MDuchemin MDuchemin
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:

                Estimated:
                Original Estimate - 6 hours
                6h
                Remaining:
                Time Spent - 4 hours Remaining Estimate - 2 hours
                2h
                Logged:
                Time Spent - 4 hours Remaining Estimate - 2 hours
                4h