Skip to content

Commit

Permalink
Remove wrapper
Browse files Browse the repository at this point in the history
Not only all current browsers support it, there are already places which
use the "new" properties anyway.
  • Loading branch information
nanaya committed Nov 23, 2024
1 parent cbded69 commit 9f7afe8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 24 deletions.
4 changes: 3 additions & 1 deletion app/javascript/src/classes/browser_view.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -991,7 +991,9 @@ export default class BrowserView

# this.image_window_size is the size of the area where the image is visible.
update_image_window_size: ->
@image_window_size = getWindowSize()
@image_window_size =
width: window.innerWidth
height: window.innerHeight

# If the thumb bar is shown, exclude it from the window height and fit the image
# in the remainder. Since the bar is at the bottom, we don't need to do anything to
Expand Down
26 changes: 3 additions & 23 deletions app/javascript/src/legacy/common.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -94,27 +94,10 @@ window.onerror = (error, file, line) ->
return

### Return the squared distance between two points. ###

window.distance_squared = (x1, y1, x2, y2) ->
(x1 - x2) ** 2 + (y1 - y2) ** 2

### Return the size of the window. ###

window.getWindowSize = ->
size = {}
if window.innerWidth?
size.width = window.innerWidth
size.height = window.innerHeight
else

### IE: ###

size.width = document.documentElement.clientWidth
size.height = document.documentElement.clientHeight
size

### If 2d canvases are supported, return one. Otherwise, return null. ###

window.create_canvas_2d = ->
document.createElement('canvas')

Expand Down Expand Up @@ -523,17 +506,14 @@ WindowDragElementAbsolute::ondrag = (e) ->
scrollLeft = @scroll_anchor_x + e.aX
scrollTop = @scroll_anchor_y + e.aY

### Don't allow dragging the image off the screen; there'll be no way to
# Don't allow dragging the image off the screen; there'll be no way to
# get it back.
###

window_size = getWindowSize()
min_visible = Math.min(100, @element.offsetWidth)
scrollLeft = Math.max(scrollLeft, min_visible - (@element.offsetWidth))
scrollLeft = Math.min(scrollLeft, window_size.width - min_visible)
scrollLeft = Math.min(scrollLeft, window.innerWidth - min_visible)
min_visible = Math.min(100, @element.offsetHeight)
scrollTop = Math.max(scrollTop, min_visible - (@element.offsetHeight))
scrollTop = Math.min(scrollTop, window_size.height - min_visible)
scrollTop = Math.min(scrollTop, window.innerHeight - min_visible)
@element.setStyle
left: scrollLeft + 'px'
top: scrollTop + 'px'
Expand Down

0 comments on commit 9f7afe8

Please sign in to comment.