Summary Files Commits Branches @commit @diff @stats
path: root / src / comparison-sliders.less
blob: 84a7a3175f24daa28dbf3dd0bb5c3b00c4c6e7c3 (plain) (blame)
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
// Image comparison slider
// Credit: http://codepen.io/solipsistacp/pen/Gpmaq
.comparison-slider {
  height: 50vh;
  overflow: hidden;
  position: relative;
  width: 100%;

  .comparison-before,
  .comparison-after {
    height: 100%;
    left: 0;
    margin: 0;
    overflow: hidden;
    position: absolute;
    top: 0;

    img {
      height: 100%;
      object-fit: none;
      object-position: left top;
      position: absolute;
      width: 100%;
      z-index: -1;
    }
  }

  .comparison-before {
    width: 100%;

    .comparison-label {
      right: 1.6rem;
    }
  }

  .comparison-after {
    max-width: 100%;
    min-width: 0;
    z-index: @zindex-0;

    &::before {
      background: transparent;
      content: "";
      cursor: default;
      height: 100%;
      left: 0;
      position: absolute;
      right: 1.6rem;
      top: 0;
      z-index: @zindex-0;
    }

    &::after {
      background: currentColor;
      border-radius: 50%;
      box-shadow: 0 -.5rem, 0 .5rem;
      color: @light-color;
      content: "";
      height: .3rem;
      position: absolute;
      right: .8rem;
      top: 50%;
      transform: translate(50%, -50%);
      width: .3rem;
      z-index: -@zindex-0;
    }

    .comparison-label {
      left: 1.6rem;
    }
  }

  .comparison-resizer {
    animation: first-run 1.5s 1 ease-in-out;
    cursor: ew-resize;
    height: 1.5rem;
    left: 0;
    max-width: 100%;
    min-width: 1.6rem;
    opacity: 0;
    outline: none;
    position: relative;
    resize: horizontal;
    top: 50%;
    transform: translateY(-50%) scaleY(30);
    width: 0;
  }

  .comparison-label {
    background: fade(@dark-color, 50%);
    bottom: 1.6rem;
    color: @light-color;
    padding: .3rem .8rem;
    position: absolute;
    user-select: none;
  }
}

@keyframes first-run {
  0% {
    width: 0;
  }
  25% {
    width: 4.8rem;
  }
  50% {
    width: 1.6rem;
  }
  75% {
    width: 2.4rem;
  }
  100% {
    width: 0;
  }
}