diff --git a/example/index.html b/example/index.html
index 81f7d6d..08ac532 100644
--- a/example/index.html
+++ b/example/index.html
@@ -16,10 +16,6 @@
box-sizing: border-box;
}
- *:focus {
- outline: none;
- }
-
.floating-focus-enabled :focus, .floating-focus-enabled .focus {
outline: dodgerblue solid 3px;
outline-offset: 4px;
@@ -70,22 +66,24 @@
border: 0;
}
- label {
- position: relative;
- overflow: hidden;
- }
-
- .file-upload-label.focus {
+ input[type=text]:nth-of-type(2):focus,
+ input[type=text]:nth-of-type(2).focus {
outline-offset: 0;
outline-color: orange;
outline-width: 2px;
outline-style: dashed;
}
+ label {
+ position: relative;
+ overflow: hidden;
+ }
+
input[type="file"] {
position: absolute;
- bottom: 200%;
- right: 200%;
+ width: 1px;
+ height: 1px;
+ z-index: -1;
}
.input-warning-wrapper {
@@ -96,9 +94,11 @@
box-sizing: border-box;
transition: max-height .25s ease;
}
+
.input-warning-wrapper > p {
margin: 0;
}
+
.input-warning-wrapper.show {
max-height: 50px;
}
diff --git a/src/floating-focus.js b/src/floating-focus.js
index d8335f0..6325fdb 100644
--- a/src/floating-focus.js
+++ b/src/floating-focus.js
@@ -83,8 +83,6 @@ export default class FloatingFocus {
}
this.floater.classList.add('visible');
- this.floater.classList.add('helper');
- this.floater.classList.add('moving');
const focusTargetAttribute = target.getAttribute('focus-target');
if (focusTargetAttribute) {
@@ -100,12 +98,10 @@ export default class FloatingFocus {
this.resolveTargetOutlineStyle(this.target, this.floater);
this.repositionElement(this.target, this.floater);
+ // Override default styles after styling the floater
this.target.classList.add('floating-focused');
- this.handleFloaterMove();
-
- clearTimeout(this.helperFadeTimeout);
- this.helperFadeTimeout = setTimeout(() => this.floater.classList.remove('helper'), HELPER_FADE_TIME);
+ this.showHelper();
}
handleBlur() {
@@ -138,19 +134,10 @@ export default class FloatingFocus {
clearInterval(this.monitorElementPositionInterval);
}
- handleFloaterMove() {
- if (this.floaterIsMoving) {
- return;
- }
-
- this.floaterIsMoving = true;
-
- const removeMovingClass = () => {
- this.floater.classList.remove('moving');
- this.floater.removeEventListener('transitionend', removeMovingClass);
- this.floaterIsMoving = false;
- }
- this.floater.addEventListener('transitionend', removeMovingClass.bind(this));
+ showHelper() {
+ this.floater.classList.add('helper');
+ clearTimeout(this.helperFadeTimeout);
+ this.helperFadeTimeout = setTimeout(() => this.floater.classList.remove('helper'), HELPER_FADE_TIME);
}
addPixels(pixels1, pixels2) {
@@ -218,9 +205,7 @@ export default class FloatingFocus {
return;
}
- this.floater.classList.add('moving');
this.repositionElement(this.target, this.floater);
- this.handleFloaterMove();
}
repositionElement(target, floater) {
diff --git a/src/floating-focus.scss b/src/floating-focus.scss
index 85fc0e1..d8382a1 100644
--- a/src/floating-focus.scss
+++ b/src/floating-focus.scss
@@ -10,11 +10,9 @@
overflow: hidden;
z-index: 9999999999; // It should always be on top of everything, no matter what.
- &.moving {
- transition-property: opacity, left, top, width, height, border-width, border-radius;
- transition-duration: .2s, .1s, .1s, .1s, .1s, .1s, .1s;
- transition-timing-function: linear, ease, ease, ease, ease, ease, ease;
- }
+ transition-property: opacity, left, top, width, height, border-width, border-radius;
+ transition-duration: .2s, .1s, .1s, .1s, .1s, .1s, .1s;
+ transition-timing-function: linear, ease, ease, ease, ease, ease, ease;
&.enabled.visible {
opacity: 1;