Start sharing components as a team!Share components as a team!Join Bit to build your applications faster.Get Started Free

index

v3.8.62arrow_drop_down
v3.8.62
v3.8.61
STATUS
Passing
DOWNLOADS
69
LICENSE
MIT
VISIBILITY
Public
PUBLISHED
10 months ago
SIZE
726 B
1 contributor
Install index as a package?
Copied
npm i @bit/lusaxweb.vuesax.utils.index
Set Bit as a scoped registryLearn more
npm config set '@bit:registry' https://node.bit.dev
Files
index.js
38 Lines(34 sloc)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
export default {
  insertBody(elx){
    document.body.insertBefore(elx, document.body.firstChild)
  },
  removeBody(element) {
    let bodyx = document.body
    bodyx.removeChild(element);
  },
  changePosition(elx,content,conditional){
    let topx = 0
    let leftx = 0
    let widthx = 0
    let scrollTopx = window.pageYOffset || document.documentElement.scrollTop;
    if(elx.getBoundingClientRect().top + 300 >= window.innerHeight) {
      setTimeout( ()=> {
        if(conditional){
          topx = (elx.getBoundingClientRect().top - content.clientHeight) + scrollTopx
        } else {
          topx = (elx.getBoundingClientRect().top - content.clientHeight + elx.clientHeight) + scrollTopx
        }
      }, 1);

    } else {
      topx = conditional?(elx.getBoundingClientRect().top + elx.clientHeight) + scrollTopx + 5:elx.getBoundingClientRect().top + scrollTopx
    }

    leftx = elx.getBoundingClientRect().left
    widthx = elx.offsetWidth

    let cords = {
      left: `${leftx}px`,
      top: `${topx}px`,
      width: `${widthx}px`
    }

    return cords
  },
}