From 4d9b7d2d7072c32ca7fa03a782272006c8728d6f Mon Sep 17 00:00:00 2001 From: Gunther Brunner Date: Wed, 28 May 2014 12:18:47 +0900 Subject: [PATCH] Rotation works for the host properly now. --- .../stf/landscape/landscape-directive.js | 33 +++++++++---------- .../components/stf/screen/screen-directive.js | 14 ++++++-- 2 files changed, 28 insertions(+), 19 deletions(-) diff --git a/res/app/components/stf/landscape/landscape-directive.js b/res/app/components/stf/landscape/landscape-directive.js index ae9090eb..ebecaf16 100644 --- a/res/app/components/stf/landscape/landscape-directive.js +++ b/res/app/components/stf/landscape/landscape-directive.js @@ -2,36 +2,37 @@ module.exports = function landscapeDirective(BrowserInfo, $document, $window, $r return { restrict: 'A', link: function (scope, element, attrs) { + var body = angular.element($document[0].body) + console.log($window.orientation) if (typeof $window.orientation !== 'undefined') { if ($window.orientation === 0) { - rotateHostAndGuest(true) + rotateGuest(true) } else { - rotateHostAndGuest(false) + rotateGuest(false) } } - function rotateHostAndGuest(portrait) { - //console.log(scope.control) + function rotateGuest(portrait) { if (portrait) { - if (scope.control) { - scope.control.rotate(0) - } - angular.element($document[0].body).addClass('guest-portrait') - angular.element($document[0].body).removeClass('guest-landscape') + body.addClass('guest-portrait') + body.removeClass('guest-landscape') + + scope.$broadcast('guest-portrait') } else { - if (scope.control) { - scope.control.rotate(90) - } - angular.element($document[0].body).addClass('guest-landscape') - angular.element($document[0].body).removeClass('guest-portrait') + body.addClass('guest-landscape') + body.removeClass('guest-portrait') + + scope.$broadcast('guest-landscape') + + $window.scrollTo(0,0) } } function guestDisplayRotatated(eventData) { var isPortrait = (window.innerHeight > window.innerWidth) - rotateHostAndGuest(isPortrait) + rotateGuest(isPortrait) } if (BrowserInfo.deviceorientation) { @@ -45,8 +46,6 @@ module.exports = function landscapeDirective(BrowserInfo, $document, $window, $r } scope.$on('$destroy', off) - - } } } diff --git a/res/app/components/stf/screen/screen-directive.js b/res/app/components/stf/screen/screen-directive.js index 186c7dab..70a22685 100644 --- a/res/app/components/stf/screen/screen-directive.js +++ b/res/app/components/stf/screen/screen-directive.js @@ -150,8 +150,8 @@ module.exports = function DeviceScreenDirective($document, ScalingService, Vendo if (!loading && scope.$parent.showScreen && scope.device) { loading = true imageRender.load(scope.device.display.url + - '?width=' + boundingWidth * guestDisplayDensity + - '&height=' + boundingHeight * guestDisplayDensity + + '?width=' + Math.floor(boundingWidth * guestDisplayDensity) + + '&height=' + Math.floor(boundingHeight * guestDisplayDensity) + '&time=' + Date.now() ) } @@ -302,6 +302,16 @@ module.exports = function DeviceScreenDirective($document, ScalingService, Vendo rotation = r || 0 }) + scope.$on('guest-portrait', function () { + scope.control.rotate(0) +// updateBounds() + }) + + scope.$on('guest-landscape', function () { + scope.control.rotate(90) +// updateBounds() + }) + scope.$on('$destroy', off) } }