Esanders has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/198668

Change subject: Move drop marker to highlights layer and position absolutely
......................................................................

Move drop marker to highlights layer and position absolutely

If you append random crap to the surface, you're going to
have a bad time.

Change-Id: Ic79bddaa11e8df531b429c801ff72c3a9796b7f0
---
M src/ce/styles/nodes/ve.ce.FocusableNode.css
M src/ce/styles/ve.ce.Surface.css
M src/ce/ve.ce.Surface.js
3 files changed, 26 insertions(+), 16 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/VisualEditor/VisualEditor 
refs/changes/68/198668/1

diff --git a/src/ce/styles/nodes/ve.ce.FocusableNode.css 
b/src/ce/styles/nodes/ve.ce.FocusableNode.css
index 555c24f..a359702 100644
--- a/src/ce/styles/nodes/ve.ce.FocusableNode.css
+++ b/src/ce/styles/nodes/ve.ce.FocusableNode.css
@@ -35,13 +35,6 @@
 }
 /*csslint vendor-prefix: true, compatible-vendor-prefixes:true */
 
-.ve-ce-focusableNode-dropMarker {
-       height: 1px;
-       background: #999;
-       pointer-events: none;
-       position: absolute;
-}
-
 .ve-ce-focusableNode-highlight {
        background: #6da9f7;
        box-shadow: inset 0 0 0 1px #4C76ac;
diff --git a/src/ce/styles/ve.ce.Surface.css b/src/ce/styles/ve.ce.Surface.css
index a4c2b3e..a41ced4 100644
--- a/src/ce/styles/ve.ce.Surface.css
+++ b/src/ce/styles/ve.ce.Surface.css
@@ -44,6 +44,13 @@
        left: 0;
 }
 
+.ve-ce-surface-dropMarker {
+       height: 1px;
+       background: #999;
+       pointer-events: none;
+       position: absolute;
+}
+
 .ve-ce-surface-paste {
        position: fixed;
        top: 1em; /* Hack: Stop the viewport scrolling when the paste target is 
typed into */
diff --git a/src/ce/ve.ce.Surface.js b/src/ce/ve.ce.Surface.js
index dee9722..877e43b 100644
--- a/src/ce/ve.ce.Surface.js
+++ b/src/ce/ve.ce.Surface.js
@@ -60,7 +60,7 @@
                this.$highlightsFocused, this.$highlightsBlurred
        );
        this.$findResults = this.$( '<div>' );
-       this.$dropMarker = this.$( '<div>' ).addClass( 
've-ce-focusableNode-dropMarker' );
+       this.$dropMarker = this.$( '<div>' ).addClass( 
've-ce-surface-dropMarker oo-ui-element-hidden' );
        this.$lastDropTarget = null;
        this.lastDropPosition = null;
        this.$pasteTarget = this.$( '<div>' );
@@ -170,6 +170,7 @@
                } );
 
        // Add elements to the DOM
+       this.$highlights.append( this.$dropMarker );
        this.$element.append( this.$documentNode, this.$pasteTarget );
        this.surface.$blockers.append( this.$highlights );
        this.surface.$selections.append( this.$deactivatedSelection );
@@ -936,7 +937,8 @@
        if ( !this.relocatingNode ) {
                return;
        }
-       var $target, $dropTarget, node, dropPosition, nodeType, 
inIgnoreChildren;
+       var $target, $dropTarget, node, dropPosition, targetPosition, top, left,
+               nodeType, inIgnoreChildren;
 
        if ( !this.relocatingNode.isContent() ) {
                e.preventDefault();
@@ -968,18 +970,26 @@
                if ( this.$lastDropTarget && (
                        !this.$lastDropTarget.is( $dropTarget ) || dropPosition 
!== this.lastDropPosition
                ) ) {
-                       this.$dropMarker.detach();
+                       this.$dropMarker.addClass( 'oo-ui-element-hidden' );
                        $dropTarget = null;
                }
                if ( $dropTarget && (
                        !$dropTarget.is( this.$lastDropTarget ) || dropPosition 
!== this.lastDropPosition
                ) ) {
-                       this.$dropMarker.width( $dropTarget.width() );
-                       if ( dropPosition === 'top' ) {
-                               this.$dropMarker.insertBefore( $dropTarget );
-                       } else {
-                               this.$dropMarker.insertAfter( $dropTarget );
+                       targetPosition = $dropTarget.position();
+                       // Go beyond margins as they can overlap
+                       top = targetPosition.top + parseFloat( $dropTarget.css( 
'margin-top' ) );
+                       left = targetPosition.left + parseFloat( 
$dropTarget.css( 'margin-left' ) );
+                       if ( dropPosition === 'bottom' ) {
+                               top += $dropTarget.outerHeight();
                        }
+                       this.$dropMarker
+                               .css( {
+                                       top: top,
+                                       left: left
+                               } )
+                               .width( $dropTarget.outerWidth() )
+                               .removeClass( 'oo-ui-element-hidden' );
                }
                if ( $dropTarget !== undefined ) {
                        this.$lastDropTarget = $dropTarget;
@@ -2647,7 +2657,7 @@
                this.emit( 'relocationEnd', this.relocatingNode );
                this.relocatingNode = null;
                if ( this.$lastDropTarget ) {
-                       this.$dropMarker.detach();
+                       this.$dropMarker.addClass( 'oo-ui-element-hidden' );
                        this.$lastDropTarget = null;
                        this.lastDropPosition = null;
                }

-- 
To view, visit https://gerrit.wikimedia.org/r/198668
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic79bddaa11e8df531b429c801ff72c3a9796b7f0
Gerrit-PatchSet: 1
Gerrit-Project: VisualEditor/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Esanders <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to