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


Commits:
bf511d58 by Mark at 2016-10-06T12:36:50+02:00
CHANNELMGR-843 side causes problems

- - - - -
9149ef17 by Mark at 2016-10-10T12:35:09+02:00
CHANNELMGR-843 fix some tests

- - - - -
36862167 by Mark at 2016-10-10T12:35:17+02:00
CHANNELMGR-843 work on mobile

- - - - -


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
@@ -50,7 +50,7 @@ export class ScalingService {
 
   setPushWidth(side, pushWidth) {
     this.panels[side].pushWidth = pushWidth;
-    this._updateScaling(side);
+    this._updateScaling();
   }
 
   setViewPortWidth(viewPortWidth) {
@@ -70,21 +70,22 @@ export class ScalingService {
    * 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.
    */
-  _updateScaling(side) {
+  _updateScaling() {
     if (!this.hippoIframeJQueryElement || 
!this.hippoIframeJQueryElement.is(':visible')) {
       return;
     }
 
     const iframeWrapper = this.hippoIframeJQueryElement.parent();
     const iframeWrapperWidth = iframeWrapper.width();
+    const viewPortWidth = this.OverlaySyncService.getViewPortWidth();
     const iframeContentWidth = iframeWrapperWidth - 
(this.panels.left.pushWidth + this.panels.right.pushWidth);
     const oldScale = this.scaleFactor;
 
-    if (iframeWrapperWidth > 1280) {
-      return; // only scale when we're below 1280 width as that is our lowest 
supported width
-    }
+    let newScale = Math.min(iframeContentWidth / iframeWrapperWidth, 1);
 
-    const newScale = Math.min(iframeContentWidth / iframeWrapperWidth, 1);
+    if ((viewPortWidth !== 0 && iframeContentWidth >= viewPortWidth) || 
iframeContentWidth >= 1280) {
+      newScale = 1;
+    }
 
     if (newScale !== oldScale) {
       const iframeBase = 
this.hippoIframeJQueryElement.find('.channel-iframe-base');
@@ -119,9 +120,9 @@ export class ScalingService {
 
       if (this.panels.left.pushWidth && this.panels.right.pushWidth) {
         elementsToScale.css('transform-origin', 'top center');
-      } else if ((!this.panels.left.pushWidth && this.panels.right.pushWidth) 
|| side === 'right') {
+      } else if ((!this.panels.left.pushWidth && this.panels.right.pushWidth)) 
{
         elementsToScale.css('transform-origin', 'top left');
-      } else if ((this.panels.left.pushWidth && !this.panels.right.pushWidth) 
|| side === 'left') {
+      } else if ((this.panels.left.pushWidth && !this.panels.right.pushWidth)) 
{
         elementsToScale.css('transform-origin', 'top right');
       }
     }


=====================================
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
@@ -127,7 +127,6 @@ describe('ScalingService', () => {
   it('should do nothing when the viewport width of an uninitialized service is 
changed', () => {
     ScalingService.setViewPortWidth(720);
 
-    expect(iframeJQueryElement.css).not.toHaveBeenCalled();
     expect(elementsToScale.css).not.toHaveBeenCalled();
     expect(ScalingService.getScaleFactor()).toEqual(1.0);
   });
@@ -137,7 +136,6 @@ describe('ScalingService', () => {
     ScalingService.init(iframeJQueryElement);
     ScalingService.setViewPortWidth(0);
 
-    
expect(iframeJQueryElement.css.calls.mostRecent().args).toEqual(['transform', 
'translateX(0)']);
     expect(ScalingService.getScaleFactor()).toEqual(1.0);
   });
 
@@ -146,7 +144,6 @@ describe('ScalingService', () => {
     ScalingService.init(iframeJQueryElement);
     ScalingService.setViewPortWidth(720);
 
-    
expect(iframeJQueryElement.css.calls.mostRecent().args).toEqual(['transform', 
'translateX(0)']);
     expect(ScalingService.getScaleFactor()).toEqual(1.0);
   });
 
@@ -157,24 +154,18 @@ describe('ScalingService', () => {
 
     expect(elementsToScale.css.calls.mostRecent().args).toEqual(['transform', 
'scale(0.5)']);
     expect(ScalingService.getScaleFactor()).toEqual(0.5);
-
-    
expect(iframeJQueryElement.css.calls.mostRecent().args).toEqual(['transform', 
'translateX(-400)']);
   });
 
-  it('should start shifting and scaling when pushing the visible canvas width 
below the viewport width', () => {
+  it('should start scaling when pushing the visible canvas width below the 
viewport width', () => {
     canvasJQueryElement.width(800);
     ScalingService.init(iframeJQueryElement);
     ScalingService.setViewPortWidth(720);
 
     // reset all relevant spies
     elementsToScale.css.calls.reset();
-    iframeJQueryElement.css.calls.reset();
 
     ScalingService.setPushWidth('left', 260);
 
-    // validate shifting
-    
expect(iframeJQueryElement.css.calls.mostRecent().args).toEqual(['transform', 
'translateX(80)']);
-
     // validate scaling
     expect(elementsToScale.css).toHaveBeenCalledWith('transform', 
'scale(0.75)');
     expect(ScalingService.getScaleFactor()).toBe(0.75);
@@ -188,16 +179,10 @@ describe('ScalingService', () => {
 
     // reset all relevant spies
     elementsToScale.css.calls.reset();
-    iframeJQueryElement.css.calls.reset();
-
-    iframeJQueryElement.css.and.returnValue('matrix(1, 0, 0, 1, 0, 0)'); // 
current shift
     canvasJQueryElement.width(720); // current canvas width
 
     ScalingService.setViewPortWidth(360);
 
-    // validate shifting
-    
expect(iframeJQueryElement.css.calls.mostRecent().args).toEqual(['transform', 
'translateX(260)']);
-
     // validate scaling
     expect(elementsToScale.css.calls.mostRecent().args).toEqual(['transform', 
'scale(1)']);
     expect(ScalingService.getScaleFactor()).toBe(1);



View it on GitLab: 
https://code.onehippo.org/cms-community/hippo-addon-channel-manager/compare/8161d1acaadb9346143fb5379de60f7f089b148c...36862167b203eccb2cf769f4dcc4decc602361f3
_______________________________________________
Hippocms-svn mailing list
Hippocms-svn@lists.onehippo.org
https://lists.onehippo.org/mailman/listinfo/hippocms-svn

Reply via email to