Mark Lenser pushed to branch feature/visual-editing-psp1-CHANNELMGR-843 at 
cms-community / hippo-addon-channel-manager


Commits:
9d961a77 by Mark at 2016-09-22T14:57:26+02:00
CHANNELMGR-843 we are always animating with css now

- - - - -


2 changed files:

- frontend-ng/src/angularjs/channel/hippoIframe/scaling.service.js
- frontend-ng/src/angularjs/channel/hippoIframe/scaling.service.spec.js


Changes:

=====================================
frontend-ng/src/angularjs/channel/hippoIframe/scaling.service.js
=====================================
--- a/frontend-ng/src/angularjs/channel/hippoIframe/scaling.service.js
+++ b/frontend-ng/src/angularjs/channel/hippoIframe/scaling.service.js
@@ -69,7 +69,6 @@ export class ScalingService {
    * The iframe should be shifted right (by controlling the translateX) if the 
left side panel is open,
    * and if the viewport width is less than the available canvas
    *
-   * @param animate  flag indicating whether any shift-change should be 
automated or immediate.
    * @returns {*[]}  canvasWidth is the maximum width available to the iframe
    *                 viewPortWidth indicates how many pixels wide the iframe 
content should be rendered.
    */
@@ -93,13 +92,9 @@ export class ScalingService {
    *
    * We compute the new scale factor and compare it to the old one. In case of 
a change, we zoom the "elementsToScale",
    * i.e. the iframe and the overlay, in or out. In case the scale factor 
changes due to opening/closing the left side panel,
-   * which is animated by material, we also animate the zooming and do an 
attempt to keep the scroll position of the
-   * iframe unchanged. Other changes (window resize, viewport width change) 
are not animated and we don't worry much
-   * about the scroll position.
-   *
-   * @param animate  flag indicating that any change should be animated.
+   * which is animated by material, we also animate the zooming and do an 
attempt to keep the scroll position of the iframe unchanged.
    */
-  _updateScaling(side, animate) {
+  _updateScaling(side) {
     if (!this.hippoIframeJQueryElement || 
!this.hippoIframeJQueryElement.is(':visible')) {
       return;
     }
@@ -120,36 +115,32 @@ export class ScalingService {
       }
       elementsToScale.velocity('finish');
 
-      if (animate) {
-        const iframeBaseJQueryElement = 
this.hippoIframeJQueryElement.find('.channel-iframe-base');
-        const currentOffset = iframeBaseJQueryElement.scrollTop();
-        const targetOffset = oldScale === 1.0 ? newScale * currentOffset : 
currentOffset / oldScale;
-
-        if (targetOffset !== currentOffset) {
-          // keep scroll-position constant during animation
-          elementsToScale.velocity('scroll', {
-            container: iframeBaseJQueryElement,
-            offset: targetOffset - currentOffset,
-            duration: this.scaleDuration,
-            easing: this.scaleEasing,
-            queue: false,
-          });
-        }
-        elementsToScale.css('transform', `scale(${newScale})`);
-      } else {
-        elementsToScale.css('transform', `scale(${newScale})`);
+      const iframeBaseJQueryElement = 
this.hippoIframeJQueryElement.find('.channel-iframe-base');
+      const currentOffset = iframeBaseJQueryElement.scrollTop();
+      const targetOffset = oldScale === 1.0 ? newScale * currentOffset : 
currentOffset / oldScale;
+
+      if (targetOffset !== currentOffset) {
+        // keep scroll-position constant during animation
+        elementsToScale.velocity('scroll', {
+          container: iframeBaseJQueryElement,
+          offset: targetOffset - currentOffset,
+          duration: this.scaleDuration,
+          easing: this.scaleEasing,
+          queue: false,
+        });
       }
+      elementsToScale.css('transform', `scale(${newScale})`);
     }
     this.scaleFactor = newScale;
   }
 
-  _resyncScaling(animate) {
+  _resyncScaling() {
     if (!this.hippoIframeJQueryElement || 
!this.hippoIframeJQueryElement.is(':visible')) {
       return;
     }
     const elementsToScale = this.hippoIframeJQueryElement.find('.cm-scale');
     const side = (elementsToScale.hasClass('cm-scale-to-left') ? 'right' : 
'left');
 
-    this._updateScaling(side, animate);
+    this._updateScaling(side);
   }
 }


=====================================
frontend-ng/src/angularjs/channel/hippoIframe/scaling.service.spec.js
=====================================
--- a/frontend-ng/src/angularjs/channel/hippoIframe/scaling.service.spec.js
+++ b/frontend-ng/src/angularjs/channel/hippoIframe/scaling.service.spec.js
@@ -59,7 +59,7 @@ describe('ScalingService', () => {
     expect(ScalingService.getScaleFactor()).toEqual(1.0);
   });
 
-  it('should change the scaling factor animated when setting pushWidth', () => 
{
+  it('should change the scaling factor when setting pushWidth', () => {
     canvasJQueryElement.width(400);
 
     ScalingService.init(iframeJQueryElement);
@@ -69,7 +69,7 @@ describe('ScalingService', () => {
     expect(ScalingService.getScaleFactor()).toEqual(0.75);
   });
 
-  it('should reset the scaling factor animated to 1.0 when setting pushWidth 
to 0', () => {
+  it('should reset the scaling factor to 1.0 when setting pushWidth to 0', () 
=> {
     canvasJQueryElement.width(400);
 
     ScalingService.init(iframeJQueryElement);



View it on GitLab: 
https://code.onehippo.org/cms-community/hippo-addon-channel-manager/commit/9d961a774370f2f79e7111bb28652116016df775
_______________________________________________
Hippocms-svn mailing list
Hippocms-svn@lists.onehippo.org
https://lists.onehippo.org/mailman/listinfo/hippocms-svn

Reply via email to