Sha256: a979663393d52223f171b7ba175241a0c984cef855bba33b196c8dbea43ed25c
Contents?: true
Size: 1.55 KB
Versions: 4
Compression:
Stored size: 1.55 KB
Contents
@CharacterEditor.Toolbar._setPosition = -> $contentView = $(@options.viewSelector) $arrow = @$elem.children('.character-editor-toolbar-arrow') $toolbarWidth = @$elem.width() $toolbarLeft = @$elem.position().left contentLeftOffset = $contentView.offset().left contentTopOffset = $contentView.offset().top contentScrollTop = $contentView.scrollTop() contentInnerWidth = $contentView.innerWidth() selection = window.getSelection() range = selection.getRangeAt(0) boundary = range.getBoundingClientRect() offsetWidth = @$elem.get(0).offsetWidth offsetHeight = @$elem.get(0).offsetHeight defaultLeft = (@options.diffLeft) - (offsetWidth / 2) middleBoundary = (boundary.left + boundary.right) / 2 - contentLeftOffset halfOffsetWidth = offsetWidth / 2 @$elem.css 'top', boundary.top + @options.diffTop - contentTopOffset + contentScrollTop - offsetHeight + 'px' edgeOffset = 5 # TODO: some issues still happen here, on double click (right edge) and right edge text selection if middleBoundary < halfOffsetWidth @$elem.css { left: "#{edgeOffset}px", right: 'auto' } $arrow.css { 'margin-left': -($toolbarWidth/2 - middleBoundary + 10) } # arrow to left else if (contentInnerWidth - middleBoundary) <= halfOffsetWidth @$elem.css { left: 'auto', right: "#{edgeOffset}px" } $arrow.css { 'margin-left': (middleBoundary - $toolbarLeft - $toolbarWidth/2 - 5) } # arrow to right else @$elem.css { left: defaultLeft + middleBoundary + 'px', right: 'auto' } $arrow.css { 'margin-left': '' } # center arrow
Version data entries
4 entries across 4 versions & 1 rubygems