Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <div class="wrapper">

  <div class="tablet-phone">
    <div class="tablet-screen">
      <div class="swipe-bar" id="swipe-wrap">
        <div class="top-swipe">
          <div class="swipe-item">
            <div class="swipe-item-left">
              <div class="item-title">
                Кроссовки женские Michael Kors 43T9CSFS2D
              </div>
              <div class="item-art">
                Арт. 65YU-X64-646
              </div>
            </div>
            <div class="swipe-item-right">
              <div class="price-title">
                Цена:
              </div>
              <div class="price-num">
                125$
              </div>
            </div>
          </div>
        </div>

        <div class="content-swiper">
          Lorem ipsum dolor, sit amet consectetur adipisicing elit. Delectus quidem placeat odio dolorum recusandae consequuntur, quae dolores laborum aut aperiam reprehenderit iusto natus illum fuga aliquam neque aliquid distinctio magnam.
          Lorem ipsum dolor, sit amet consectetur adipisicing elit. Delectus quidem placeat odio dolorum recusandae consequuntur, quae dolores laborum aut aperiam reprehenderit iusto natus illum fuga aliquam neque aliquid distinctio magnam.
          Lorem ipsum dolor, sit amet consectetur adipisicing elit. Delectus quidem placeat odio dolorum recusandae consequuntur, quae dolores laborum aut aperiam reprehenderit iusto natus illum fuga aliquam neque aliquid distinctio magnam.
          Lorem ipsum dolor, sit amet consectetur adipisicing elit. Delectus quidem placeat odio dolorum recusandae consequuntur, quae dolores laborum aut aperiam reprehenderit iusto natus illum fuga aliquam neque aliquid distinctio magnam.
          Lorem ipsum dolor, sit amet consectetur adipisicing elit. Delectus quidem placeat odio dolorum recusandae consequuntur, quae dolores laborum aut aperiam reprehenderit iusto natus illum fuga aliquam neque aliquid distinctio magnam.
          Lorem ipsum dolor, sit amet consectetur adipisicing elit. Delectus quidem placeat odio dolorum recusandae consequuntur, quae dolores laborum aut aperiam reprehenderit iusto natus illum fuga aliquam neque aliquid distinctio magnam.
          Lorem ipsum dolor, sit amet consectetur adipisicing elit. Delectus quidem placeat odio dolorum recusandae consequuntur, quae dolores laborum aut aperiam reprehenderit iusto natus illum fuga aliquam neque aliquid distinctio magnam.
          Lorem ipsum dolor, sit amet consectetur adipisicing elit. Delectus quidem placeat odio dolorum recusandae consequuntur, quae dolores laborum aut aperiam reprehenderit iusto natus illum fuga aliquam neque aliquid distinctio magnam.
          Lorem ipsum dolor, sit amet consectetur adipisicing elit. Delectus quidem placeat odio dolorum recusandae consequuntur, quae dolores laborum aut aperiam reprehenderit iusto natus illum fuga aliquam neque aliquid distinctio magnam.
          Lorem ipsum dolor, sit amet consectetur adipisicing elit. Delectus quidem placeat odio dolorum recusandae consequuntur, quae dolores laborum aut aperiam reprehenderit iusto natus illum fuga aliquam neque aliquid distinctio magnam.
          Lorem ipsum dolor, sit amet consectetur adipisicing elit. Delectus quidem placeat odio dolorum recusandae consequuntur, quae dolores laborum aut aperiam reprehenderit iusto natus illum fuga aliquam neque aliquid distinctio magnam.
          Lorem ipsum dolor, sit amet consectetur adipisicing elit. Delectus quidem placeat odio dolorum recusandae consequuntur, quae dolores laborum aut aperiam reprehenderit iusto natus illum fuga aliquam neque aliquid distinctio magnam.
          Lorem ipsum dolor, sit amet consectetur adipisicing elit. Delectus quidem placeat odio dolorum recusandae consequuntur, quae dolores laborum aut aperiam reprehenderit iusto natus illum fuga aliquam neque aliquid distinctio magnam.
          Lorem ipsum dolor, sit amet consectetur adipisicing elit. Delectus quidem placeat odio dolorum recusandae consequuntur, quae dolores laborum aut aperiam reprehenderit iusto natus illum fuga aliquam neque aliquid distinctio magnam.consequuntur, quae dolores laborum aut aperiam reprehenderit iusto natus illum fuga aliquam neque aliquid distinctio magnam.
          Lorem ipsum dolor, sit amet consectetur adipisicing elit. Delectus quidem placeat odio dolorum recusandae consequuntur, quae dolores laborum aut aperiam reprehenderit iusto natus illum fuga aliquam neque aliquid distinctio magnam.
          Lorem ipsum dolor, sit amet consectetur adipisicing elit. Delectus quidem placeat odio dolorum recusandae consequuntur, quae dolores laborum aut aperiam reprehenderit iusto natus illum fuga aliquam neque aliquid distinctio magnam.
          Lorem ipsum dolor, sit amet consectetur adipisicing elit. Delectus quidem placeat odio dolorum recusandae consequuntur, quae dolores laborum aut aperiam reprehenderit iusto natus illum fuga aliquam neque aliquid distinctio magnam.
          Lorem ipsum dolor, sit amet consectetur adipisicing elit. Delectus quidem placeat odio dolorum recusandae consequuntur, quae dolores laborum aut aperiam reprehenderit iusto natus illum fuga aliquam neque aliquid distinctio magnam.
          Lorem ipsum dolor, sit amet consectetur adipisicing elit. Delectus quidem placeat odio dolorum recusandae consequuntur, quae dolores laborum aut aperiam reprehenderit iusto natus illum fuga aliquam neque aliquid distinctio magnam.
          Lorem ipsum dolor, sit amet consectetur adipisicing elit. Delectus quidem placeat odio dolorum recusandae consequuntur, quae dolores laborum aut aperiam reprehenderit iusto natus illum fuga aliquam neque aliquid distinctio magnam.
          Lorem ipsum dolor, sit amet consectetur adipisicing elit. Delectus quidem placeat odio dolorum recusandae consequuntur, quae dolores laborum aut aperiam reprehenderit iusto natus illum fuga aliquam neque aliquid distinctio magnam.
        </div>
      </div>
    </div>
  </div>

</div>

              
            
!

CSS

              
                * {
	-webkit-box-sizing: border-box;
	-moz-box-sizing: border-box;
	box-sizing: border-box;}

img {
	max-width: 100%;
	height: auto;
	vertical-align: top;
}
	
body {
	font-family: 'Roboto', sans-serif;
  font-size: 16px;
  line-height: 1.6;
}
	
a {}

a:hover {}

.wrapper {
	position: absolute;
	left: 0;
	top: 0;
	width: 100%;
	height: 100%;
	display: flex;
	justify-content: center;
	align-items: center;
	align-content: center;
}

.tablet-phone {
	position: absolute;
	max-width: 812px; // 44 tablet border
	width: 100%;
	border-top: 20px solid #000;
	border-right: 20px solid #000;
	border-left: 20px solid #000;
	border-bottom: 50px solid #000;
	border-radius: 20px;
	max-height: 1068px;
	top: 20px;
	bottom: 20px;
	background-color: #ccc;

	&:after {
		content: '';
		position: absolute;
		width: 80px;
		height: 24px;
		border: 1px solid #ccc;
		bottom: -36px;
		left: 50%;
		margin-left: -40px;
		border-radius: 10px;
	}

	&:before {
		content: '';
		position: absolute;
		width: 14px;
		height: 14px;
		border: 1px solid #ccc;
		top: -17px;
		left: 50%;
		margin-left: -7px;
		border-radius: 10px;
	}
}

.tablet-screen {
	position: absolute;
	left: 0;
	top: 0;
	right: 0;
	bottom: 0;
	background-image: url(https://source.unsplash.com/random);
	background-size: cover;
	overflow: hidden;

	&:after {
		content: '';
		background-color: rgba(0,0,0,0.3);
		position: absolute;
		left: 0;
		top: 0;
		width: 100%;
		height: 100%;
	}
}

.swipe-bar {
	position: absolute;
	z-index: 99;
	width: 100%;
	left: 0;
	min-height: 100px;
	background-color: #fff;
	border-radius: 15px 15px 0 0;
	top: 100%;
	margin-top: -100px;
	float: left;
	max-height: calc(100vh - 100px);

	&.anim {
		transition: all 0.3s;
	}

	&.show {
		overflow: auto;
		touch-action: pan-down !important;
	}

	&.canScroll {
		touch-action: auto !important;
		-webkit-user-drag: auto !important;
	}
}

.top-swipe {
	float: left;
	width: 100%;
	position: relative;
  min-height: 80px;
	padding: 20px 20px 0;

	&:before {
		content: '';
		position: absolute;
		left: 50%;
		background-color: #ccc;
		top: 7px;
		border-radius: 3px;
		width: 36px;
		height: 5px;
		margin-left: -18px;
	}
}

.swipe-item {
	float: left;
	width: 100%;
}

.swipe-item-left {
	float: left;
	width: calc(100% - 200px);
}

.item-title {
	font-size: 20px;
}

.item-art {
	font-size: 14px;
	color: #666666;
}

.swipe-item-right {
	float: right;
	width: 200px;
	text-align: right;
}

.price-title {
	font-size: 12px;
}

.price-num {
	font-size: 22px;
	font-weight: bold;
}

.content-swiper {
	float: left;
	width: 100%;
	padding: 25px 20px;
}



              
            
!

JS

              
                var swipeEl = document.getElementById('swipe-wrap');
var mcSwipe = new Hammer.Manager(swipeEl);

var SWIPE_PLAYER_HEIGHT = window.innerHeight - 100;
var DISPLAY_SWIPE_THRESHOLD = SWIPE_PLAYER_HEIGHT / 2.5;

var lastPosY = 0;
var isDragging = false;
var canSwipeUpDown = false;
var isOpen = false;

function getTranslate3d(setting = '') {
    var values = setting.split(/\w+\(|\);?/);

    if (!values[1] || !values[1].length) {
        return [];
    }

    return values[1].split(/,\s?/g).map(value => parseInt(value, 10));
}

function setTranslate3dPosY(posY) {
    return 'translate3d(0,' + posY + 'px, 0)';
}

function hideswipeEl(elem) {
    isOpen = false;
    elem.classList.add("hide");
    elem.classList.remove("show");
    elem.classList.remove("canScroll");
    elem.style.transform = 'translate3d(0, 0px, 0)';
    lastPosY = getTranslate3d(elem.style.transform)[1];
}

function showNow(elem) {
    setTimeout(function () { isOpen = true }, 500);

    elem.classList.remove("hide");
    elem.classList.add("show");
    var topPos = - window.innerHeight + 300;
    elem.style.transform = 'translate3d(0,' + topPos + 'px, 0)';
    lastPosY = getTranslate3d(elem.style.transform)[1];
}

function displayswipeEl(elem = swipeEl) {
    elem.style.transform = 'translate3d(0, 0, 0)';
    elem.classList.remove("hide");
}

function handleDrag(ev) {
    var direction = ev.offsetDirection;
    var directionDown = direction === 16;

    swipeEl.addEventListener(
        'scroll',
        function () {
            var scrollTop = swipeEl.scrollTop;
            if (scrollTop == 0) {
                canSwipeUpDown = false;
                isOpen = false;
                swipeEl.classList.remove('canScroll');
            }
            else {
                canSwipeUpDown = true;
                isOpen = true;

                swipeEl.classList.add('canScroll');
            }
        },
        false
    )

    if (isOpen && !directionDown) {
        setTranslate3dPosY(0);
        console.log('is open');
        canSwipeUpDown = true;
        swipeEl.classList.add('canScroll');
    }
    else if (!canSwipeUpDown) {
        swipeEl.classList.remove('canScroll');
        console.log('is open but scroll UP');
        var elem = swipeEl;

        // DRAG STARTED
        if (!isDragging) {
            console.log('start');
            elem.classList.remove('anim');
            isDragging = true;
            var currentPosY = getTranslate3d(elem.style.transform)[1];
            lastPosY = currentPosY ? currentPosY : 0;
        }

        var posY = ev.deltaY + lastPosY;
        elem.style.transform = setTranslate3dPosY(posY);

        // DRAG ENDED
        if (ev.isFinal) {
            console.log('end');

            elem.classList.add('anim');
            isDragging = false;

            if (Math.abs(posY) < DISPLAY_SWIPE_THRESHOLD) {
                hideswipeEl(elem);
            }
            else {
                showNow(elem);


            }

        }
    }
}

mcSwipe.add(new Hammer.Pan({
    direction: Hammer.DIRECTION_ALL,
    threshold: 0
}));
mcSwipe.on("pan", handleDrag);

              
            
!
999px

Console