OLD | NEW |
1 // Copyright 2014 The ChromeOS IME Authors. All Rights Reserved. | 1 // Copyright 2014 The ChromeOS IME Authors. All Rights Reserved. |
2 // limitations under the License. | 2 // limitations under the License. |
3 // See the License for the specific language governing permissions and | 3 // See the License for the specific language governing permissions and |
4 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 4 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
5 // distributed under the License is distributed on an "AS-IS" BASIS, | 5 // distributed under the License is distributed on an "AS-IS" BASIS, |
6 // Unless required by applicable law or agreed to in writing, software | 6 // Unless required by applicable law or agreed to in writing, software |
7 // | 7 // |
8 // http://www.apache.org/licenses/LICENSE-2.0 | 8 // http://www.apache.org/licenses/LICENSE-2.0 |
9 // | 9 // |
10 // You may obtain a copy of the License at | 10 // You may obtain a copy of the License at |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 /** | 140 /** |
141 * Given a mouse or touch event, figure out the coordinates where it occurred. | 141 * Given a mouse or touch event, figure out the coordinates where it occurred. |
142 * | 142 * |
143 * @param {goog.events.BrowserEvent} e Event. | 143 * @param {goog.events.BrowserEvent} e Event. |
144 * @return {!i18n.input.hwt.StrokeHandler.Point} a point. | 144 * @return {!i18n.input.hwt.StrokeHandler.Point} a point. |
145 * @private | 145 * @private |
146 */ | 146 */ |
147 i18n.input.hwt.StrokeHandler.prototype.getPoint_ = function(e) { | 147 i18n.input.hwt.StrokeHandler.prototype.getPoint_ = function(e) { |
148 var pos = goog.style.getPageOffset(this.canvas_); | 148 var pos = goog.style.getPageOffset(this.canvas_); |
149 var nativeEvent = e.getBrowserEvent(); | 149 var nativeEvent = e.getBrowserEvent(); |
| 150 var scrollX = (document.dir == 'rtl' ? -1 : 1) * ( |
| 151 document.body.scrollLeft || |
| 152 document.documentElement.scrollLeft || 0); |
| 153 var scrollY = document.body.scrollTop || |
| 154 document.documentElement.scrollTop || 0; |
150 var x, y; | 155 var x, y; |
151 if (!goog.userAgent.IE && nativeEvent.pageX && nativeEvent.pageY) { | 156 if (nativeEvent.touches != null && nativeEvent.touches.length > 0) { |
| 157 x = nativeEvent.touches[0].clientX + scrollX; |
| 158 y = nativeEvent.touches[0].clientY + scrollY; |
| 159 } else if (!goog.userAgent.IE && nativeEvent.pageX && nativeEvent.pageY) { |
152 x = nativeEvent.pageX; | 160 x = nativeEvent.pageX; |
153 y = nativeEvent.pageY; | 161 y = nativeEvent.pageY; |
154 } else { | 162 } else { |
155 var scrollX = (document.dir == 'rtl' ? -1 : 1) * ( | |
156 document.body.scrollLeft || | |
157 document.documentElement.scrollLeft || 0); | |
158 var scrollY = document.body.scrollTop || | |
159 document.documentElement.scrollTop || 0; | |
160 x = nativeEvent.clientX + scrollX; | 163 x = nativeEvent.clientX + scrollX; |
161 y = nativeEvent.clientY + scrollY; | 164 y = nativeEvent.clientY + scrollY; |
162 } | 165 } |
163 if (nativeEvent.touches != null && nativeEvent.touches.length > 0) { | |
164 x = nativeEvent.touches[0].clientX; | |
165 y = nativeEvent.touches[0].clientY; | |
166 } | |
167 return new i18n.input.hwt.StrokeHandler.Point(x - pos.x, y - pos.y, | 166 return new i18n.input.hwt.StrokeHandler.Point(x - pos.x, y - pos.y, |
168 goog.now()); | 167 goog.now()); |
169 }; | 168 }; |
170 | 169 |
171 | 170 |
172 /** | 171 /** |
173 * Reset the drawing flag, in case the drawing canvas gets cleared while | 172 * Reset the drawing flag, in case the drawing canvas gets cleared while |
174 * stroke is being drawn. | 173 * stroke is being drawn. |
175 */ | 174 */ |
176 i18n.input.hwt.StrokeHandler.prototype.reset = function() { | 175 i18n.input.hwt.StrokeHandler.prototype.reset = function() { |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 i18n.input.hwt.StrokeHandler.StrokeEvent.base(this, 'constructor', type); | 242 i18n.input.hwt.StrokeHandler.StrokeEvent.base(this, 'constructor', type); |
244 | 243 |
245 /** | 244 /** |
246 * The point. | 245 * The point. |
247 * | 246 * |
248 * @type {!i18n.input.hwt.StrokeHandler.Point} | 247 * @type {!i18n.input.hwt.StrokeHandler.Point} |
249 */ | 248 */ |
250 this.point = point; | 249 this.point = point; |
251 }; | 250 }; |
252 goog.inherits(i18n.input.hwt.StrokeHandler.StrokeEvent, goog.events.Event); | 251 goog.inherits(i18n.input.hwt.StrokeHandler.StrokeEvent, goog.events.Event); |
OLD | NEW |