Giter Site home page Giter Site logo

besworks / pop-out Goto Github PK

View Code? Open in Web Editor NEW
3.0 1.0 0.0 405 KB

Web Component combo that allows child elements to expand out of their parent's overflow area.

Home Page: https://bes.works/bits/?pop-out

License: MIT License

JavaScript 69.71% HTML 17.26% CSS 13.03%
css overflow webcomponent

pop-out's Introduction

Pop Out!

This custom element combo provides a scrollable element with child elements that expand out of the overflow area when hovered. It was created in response to a long-standing issue with the CSS spec and this question on Stack Overflow.

How it Works

The child elements are plucked out from the static context and positioned fixed to the viewport while simultaneously inserting a placeholder of the same dimensions into the static context to prevent the layout from collapsing.

Usage

<script type="module" src="./pop-out.js"></script>
<over-scroll>
  <pop-out><img src="./your.png"></pop-out>
  <pop-out><img src="./content.svg"></pop-out>
  <pop-out><img src="./here.jpg"></pop-out>
</over-scroll>

Both element definitions are imported by the single script tag. You can also import the classes into your script and create these programatically.

import { OverScrollElement, PopOutElement } from './pop-out.js';

let overScroll = new OverScrollElement();
let popOut = new PopOutElement();
popOut.innerHTML = `<h1> Hello! </h1>`;
overScroll.append(popOut);
document.body.append(overScroll);

The outer, over-scroll element is necessary to enable scroll events to pass through the nested elements and gracefully de-zoom the active element. The default mode is to scroll horizontally. Adding a vertical attribute modifies the scroll direction and makes it display:inline-flex.

<over-scroll vertical>
   ...
</over-scroll>

You can pass any markup/elements you want into pop-out though images and center justified content tend to work best. You have full control over the styling of your content. A few default rules are applied to pop-out elements that can be overriden:

pop-out {
  display: block;
  cursor: zoom-in;
  user-select: none;
  --scale-amount: 1.5;
  --scale-speed: 0.2s;
  --scale-timing: ease;
  --shadow-in: drop-shadow(0 0 0.2rem #00000033);
  --shadow-out: drop-shadow(0 0 1rem #00000088);
}

pop-out's People

Contributors

besworks avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.