mike-jumper commented on a change in pull request #590: URL: https://github.com/apache/guacamole-client/pull/590#discussion_r574984159
########## File path: guacamole-common-js/src/main/webapp/modules/Position.js ########## @@ -0,0 +1,92 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +var Guacamole = Guacamole || {}; + +/** + * A position in 2-D space. + * + * @constructor + * @param {Guacamole.Position|Object} [template={}] + * The object whose properties should be copied within the new + * Guacamole.Mouse.State. Review comment: 🖱️ ✔️ Fixed via rebase. ########## File path: guacamole-common-js/src/main/webapp/modules/Position.js ########## @@ -0,0 +1,92 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +var Guacamole = Guacamole || {}; + +/** + * A position in 2-D space. + * + * @constructor + * @param {Guacamole.Position|Object} [template={}] + * The object whose properties should be copied within the new + * Guacamole.Mouse.State. + */ +Guacamole.Position = function Position(template) { + + template = template || {}; + + /** + * The current X position, in pixels. + * + * @type {Number} + * @default 0 + */ + this.x = template.x || 0; + + /** + * The current Y position, in pixels. + * + * @type {Number} + * @default 0 + */ + this.y = template.y || 0; + + /** + * Assigns the position represented by the given element and + * clientX/clientY coordinates. The clientX and clientY coordinates are + * relative to the browser viewport and are commonly available within + * JavaScript event objects. The final position is translated to + * coordinates that are relative the given element. + * + * @param {Element} element + * The element the coordinates should be relative to. + * + * @param {Number} clientX + * The viewport-relative X coordinate to translate. + * + * @param {Number} clientY + * The viewport-relative Y coordinate to translate. + */ + this.fromClientPosition = function fromClientPosition(element, clientX, clientY) { + + this.x = clientX - element.offsetLeft; + this.y = clientY - element.offsetTop; + + // This is all JUST so we can get the mouse position within the element Review comment: Also fixed via rebase. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected]
