OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 /** | 5 /** |
6 * @fileoverview | 6 * @fileoverview |
7 * Class handling creation and teardown of a remoting client session. | 7 * Class handling creation and teardown of a remoting client session. |
8 * | 8 * |
9 * The ClientSession class controls lifetime of the client plugin | 9 * The ClientSession class controls lifetime of the client plugin |
10 * object and provides the plugin with the functionality it needs to | 10 * object and provides the plugin with the functionality it needs to |
(...skipping 936 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
947 var stopX = { stop: false }; | 947 var stopX = { stop: false }; |
948 style.marginLeft = adjustMargin(style.marginLeft, dx, | 948 style.marginLeft = adjustMargin(style.marginLeft, dx, |
949 window.innerWidth, plugin.width, stopX); | 949 window.innerWidth, plugin.width, stopX); |
950 var stopY = { stop: false }; | 950 var stopY = { stop: false }; |
951 style.marginTop = adjustMargin(style.marginTop, dy, | 951 style.marginTop = adjustMargin(style.marginTop, dy, |
952 window.innerHeight, plugin.height, stopY); | 952 window.innerHeight, plugin.height, stopY); |
953 return stopX.stop && stopY.stop; | 953 return stopX.stop && stopY.stop; |
954 } | 954 } |
955 | 955 |
956 /** | 956 /** |
957 * Enable or disable bump-scrolling. | 957 * Enable or disable bump-scrolling. When disabling bump scrolling, also reset |
| 958 * the scroll offsets to (0, 0). |
958 * @private | 959 * @private |
959 * @param {boolean} enable True to enable bump-scrolling, false to disable it. | 960 * @param {boolean} enable True to enable bump-scrolling, false to disable it. |
960 */ | 961 */ |
961 remoting.ClientSession.prototype.enableBumpScroll_ = function(enable) { | 962 remoting.ClientSession.prototype.enableBumpScroll_ = function(enable) { |
962 if (enable) { | 963 if (enable) { |
963 /** @type {null|function(Event):void} */ | 964 /** @type {null|function(Event):void} */ |
964 this.onMouseMoveRef_ = this.onMouseMove_.bind(this); | 965 this.onMouseMoveRef_ = this.onMouseMove_.bind(this); |
965 this.plugin.element().addEventListener('mousemove', this.onMouseMoveRef_, | 966 this.plugin.element().addEventListener('mousemove', this.onMouseMoveRef_, |
966 false); | 967 false); |
967 } else { | 968 } else { |
968 this.plugin.element().removeEventListener('mousemove', this.onMouseMoveRef_, | 969 this.plugin.element().removeEventListener('mousemove', this.onMouseMoveRef_, |
969 false); | 970 false); |
970 this.onMouseMoveRef_ = null; | 971 this.onMouseMoveRef_ = null; |
| 972 this.plugin.element().style.marginLeft = 0; |
| 973 this.plugin.element().style.marginTop = 0; |
971 } | 974 } |
972 }; | 975 }; |
973 | 976 |
974 /** | 977 /** |
975 * @param {Event} event The mouse event. | 978 * @param {Event} event The mouse event. |
976 * @private | 979 * @private |
977 */ | 980 */ |
978 remoting.ClientSession.prototype.onMouseMove_ = function(event) { | 981 remoting.ClientSession.prototype.onMouseMove_ = function(event) { |
979 if (this.bumpScrollTimer_) { | 982 if (this.bumpScrollTimer_) { |
980 window.clearTimeout(this.bumpScrollTimer_); | 983 window.clearTimeout(this.bumpScrollTimer_); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1021 var lateAdjustment = 1 + (now - expected) / timeout; | 1024 var lateAdjustment = 1 + (now - expected) / timeout; |
1022 if (!that.scroll_(lateAdjustment * dx, lateAdjustment * dy)) { | 1025 if (!that.scroll_(lateAdjustment * dx, lateAdjustment * dy)) { |
1023 that.bumpScrollTimer_ = window.setTimeout( | 1026 that.bumpScrollTimer_ = window.setTimeout( |
1024 function() { repeatScroll(now + timeout); }, | 1027 function() { repeatScroll(now + timeout); }, |
1025 timeout); | 1028 timeout); |
1026 } | 1029 } |
1027 }; | 1030 }; |
1028 repeatScroll(new Date().getTime()); | 1031 repeatScroll(new Date().getTime()); |
1029 } | 1032 } |
1030 }; | 1033 }; |
OLD | NEW |