All Projects → anseki → plain-overlay

anseki / plain-overlay

Licence: MIT License
The simple library for customizable overlay which covers a page, elements or iframe-windows.

Programming Languages

javascript
184084 projects - #8 most used programming language
HTML
75241 projects

Projects that are alternatives of or similar to plain-overlay

Vue Ui For Pc
基于Vue2.x的一套PC端UI组件,包括了Carousel 跑马灯、Cascader 级联、Checkbox 多选框、Collapse 折叠面板、DatePicker 日期选择、Dialog 对话框、Form 表单、Input 输入框、InputNumber 数字输入框、Layer 弹窗层、Loading 加载、Menu 菜单、Page 分页、Progress 进度条、Radio 单选框、SelectDropDown 仿select、Switch 开关、Table 表格、Tabs 标签页、Textarea 文本框、Tooltip 文字提示、BackTop 返回顶部、steps 步骤条、Transfer 穿梭框、Tree 树形、Upload 文件上传、Lazy 图片懒加载、Loading 加载、Pagination 分页等等
Stars: ✭ 156 (+457.14%)
Mutual labels:  progress, form, loading
busy-load
A flexible loading-mask jQuery-plugin
Stars: ✭ 76 (+171.43%)
Mutual labels:  overlay, loading, busy
Waitme
jquery plugin for easy creating loading css3/images animations
Stars: ✭ 302 (+978.57%)
Mutual labels:  progress, form, loading
react-layer-stack
Layering system for React. Useful for popover/modals/tooltip/dnd application
Stars: ✭ 158 (+464.29%)
Mutual labels:  overlay, window
React Nprogress
⌛️ A React primitive for building slim progress bars.
Stars: ✭ 173 (+517.86%)
Mutual labels:  progress, loading
Spinners React
Lightweight SVG/CSS spinners for React
Stars: ✭ 254 (+807.14%)
Mutual labels:  progress, loading
Vue Loaders
Vue + loaders.css
Stars: ✭ 127 (+353.57%)
Mutual labels:  progress, loading
Boundary
Boundary is a CSS+Javascript library for Chrome extension developers to easily create HTML elements that won’t affect or be affected by the current webpage’s CSS. Strongly recommended if you are considering adding a sticker, a sidebar or any overlay box using content script.
Stars: ✭ 59 (+110.71%)
Mutual labels:  overlay, iframe
spinners-angular
Lightweight SVG/CSS spinners for Angular
Stars: ✭ 21 (-25%)
Mutual labels:  progress, loading
spinnies
Node.js module to create and manage multiple spinners in command-line interface programs
Stars: ✭ 111 (+296.43%)
Mutual labels:  progress, loading
plain-modal
The simple library for customizable modal window.
Stars: ✭ 21 (-25%)
Mutual labels:  customizable, window
jekyll-loading-lazy
🧙🏽‍♀️ Automatically adds loading="lazy" to <img> and <iframe> tags. Load images on your sites lazily without JavaScript.
Stars: ✭ 41 (+46.43%)
Mutual labels:  loading, iframe
hotscript
HotScript - Revolutionizing how Windows works.
Stars: ✭ 29 (+3.57%)
Mutual labels:  mouse, window
Vue Wait
Complex Loader and Progress Management for Vue/Vuex and Nuxt Applications
Stars: ✭ 1,869 (+6575%)
Mutual labels:  progress, loading
AMProgressHUD
A gif progress HUD for iOS.
Stars: ✭ 18 (-35.71%)
Mutual labels:  progress, loading
Aiforms.dialogs
AiForms.Dialogs for Xamarin.Forms
Stars: ✭ 143 (+410.71%)
Mutual labels:  progress, loading
CustomProgress
一款常见的进度条加载框架
Stars: ✭ 32 (+14.29%)
Mutual labels:  progress, loading
Listr2
NodeJS Task List derived from the best! Create beautiful CLI interfaces via easy and logical to implement task lists that feel alive and interactive.
Stars: ✭ 73 (+160.71%)
Mutual labels:  progress, loading
Terminal layout
The project help you to quickly build layouts in terminal,cross-platform(一个跨平台的命令行ui布局工具)
Stars: ✭ 98 (+250%)
Mutual labels:  progress, loading
lime
A library for drawing graphics on the console screen
Stars: ✭ 32 (+14.29%)
Mutual labels:  mouse, window

PlainOverlay

npm GitHub issues dependencies license

The simple library for customizable overlay which covers all or part of a web page.

Document and Examples https://anseki.github.io/plain-overlay/

ss-01 ss-02 ss-03

Features:

  • Cover all or part of a web page with an overlay.
  • Block scrolling anything under the overlay by a mouse or keys.
  • Block focusing anything under the overlay by a mouse or Tab key or access-keys.
  • Show something like a loading-animation on the overlay.
  • No dependency.
  • Single file.
  • Modern browsers are supported. (If you want to support legacy browsers such as IE 9-, see jQuery-plainOverlay.)

One of the following can be specified as the target that is covered:

  • A current window
  • An element that has a bounding-box
  • Another window (i.e. child window such as <iframe>)
  • An element in another window

Usage

Load PlainOverlay into your web page.

<script src="plain-overlay.min.js"></script>

This is simplest case:

PlainOverlay.show(); // Static method

Now, new overlay is shown and all of the page are covered with it.
You can specify an element as the target that is covered.

PlainOverlay.show(element); // element is covered

Use an instance method to hide the overlay.

var overlay = PlainOverlay.show();
// Now, new overlay is shown.
// Do something ...
overlay.hide();
// Now, the overlay is hidden.

For options and more details, refer to the following.

Constructor

overlay = new PlainOverlay([target][, options])

The target argument is an element that will be covered with the overlay, or window (or document or <html> or <body>) that means all of the web page.
Any element that has a bounding-box is accepted. It can be an element in another window (i.e. <iframe>). <iframe> is regarded as window of that <iframe>.
The default of target argument is current window.

The options argument is an Object that can have properties as options. You can also change the options by setOptions or show methods or properties of the PlainOverlay instance.

For example:

// Cover all of the web page, with `duration` option
var overlay = new PlainOverlay({duration: 400});
// Cover a part of the web page, with `face` option
var overlay = new PlainOverlay(document.getElementById('form'), {face: false});

See also: PlainOverlay.show

When you will do something about HTML document regardless of the PlainOverlay, you typically do that after the HTML document is ready (i.e. the HTML document has been loaded and parsed by web browser).
For example:

// Wait for HTML document to get ready
window.addEventListener('load', function() { // NOT `DOMContentLoaded`
  // Do something about HTML document
  var overlay = new PlainOverlay(document.getElementById('form'));
});

If you don't wait for HTML document to be ready, you might not be able to get a target element yet, or problems with incomplete layout may occur. Also, you should do so asynchronous like the above for the performance because synchronous code blocks parsing HTML.

Methods

show

self = overlay.show([force][, options])

Show the overlay.
If true is specified for force argument, show it immediately without an effect. (As to the effect, see duration option.)
If options argument is specified, call setOptions method and show the overlay. It works the same as:

overlay.setOptions(options).show();

See also: PlainOverlay.show

hide

self = overlay.hide([force])

Hide the overlay.
If true is specified for force argument, hide it immediately without an effect. (As to the effect, see duration option.)

setOptions

self = overlay.setOptions(options)

Set one or more options.
The options argument is an Object that can have properties as options.

scrollLeft, scrollTop

currentLeft = overlay.scrollLeft([newLeft[, scrollTarget]])
currentTop = overlay.scrollTop([newTop[, scrollTarget]])

Scrolling a window or element is blocked while it is covered with the overlay. scrollLeft and scrollTop methods allow it scroll, and return current value.
The value is a number of pixels that a content is scrolled to the left or upward.
The default of scrollTarget is a target of the overlay.

position

self = overlay.position()

Update the position of the overlay that covers a part of a web page.
If target is a part of a web page, the overlay is shown at the same position as the target, and it is re-positioned (and resized) as needed automatically when a window that contains the target is resized.
You should call position method if you moved or resized the target without resizing the window.

Options

face

Type: Element, boolean or undefined
Default: undefined (Builtin Face)

Something that is shown on the overlay. This is usually a message or image that means "Please wait...".
If false is specified, nothing is shown on the overlay.

For example, a message:

<div id="message">Please wait...</div>
var overlay = new PlainOverlay({face: document.getElementById('message')});

For example, an image:

<img id="image" src="loading.svg">
var overlay = new PlainOverlay({face: document.getElementById('image')});

For example, an inline SVG:

<svg id="svg" version="1.1">
  <!-- ... -->
</svg>
var overlay = new PlainOverlay({face: document.getElementById('svg')});

duration

Type: number
Default: 200

A number determining how long (milliseconds) the effect (fade-in/out) animation for showing and hiding the overlay will run.

blur

Type: number or boolean
Default: false

Applies a Gaussian blur to the target while the overlay is shown. Note that the current browser might not support it.
It is not applied if false is specified.

For example:

overlay.blur = 3;

style

Type: Object or undefined
Default: undefined

An Object that can have CSS properties that are added to the overlay.

Major properties of default style:

{
  backgroundColor: 'rgba(136, 136, 136, 0.6)',
  cursor: 'wait',
  zIndex: 9000
}

For example, whity overlay:

var overlay = new PlainOverlay({style: {backgroundColor: 'rgba(255, 255, 255, 0.6)'}});

Note that some properties that affect the layout (e.g. width, border, etc.) might not work or those might break the overlay.

If you want to change the default style (i.e. style of all overlay in the web page), you can define style rules with .plainoverlay class in your style-sheet.

For example, CSS rule-definition:

.plainoverlay {
  background-color: rgba(255, 255, 255, 0.6);
}

onShow, onHide, onBeforeShow, onBeforeHide

Type: function or undefined
Default: undefined

Event listeners:

  • onBeforeShow is called when the overlay is about to be shown. If false is returned, the showing is canceled.
  • onShow is called when a showing effect of the overlay is finished.
  • onBeforeHide is called when the overlay is about to be hidden. If false is returned, the hiding is canceled.
  • onHide is called when a hiding effect of the overlay is finished.

In the functions, this refers to the current PlainOverlay instance.

For example:

var overlay = new PlainOverlay({
  onBeforeShow: function() {
    if (name.value) {
      this.face.className = 'anim'; // Start animation
    } else {
      alert('Please input your name');
      return false; // Cancel the showing the overlay.
    }
  },
  onHide: function() {
    this.face.className = ''; // Stop animation
  }
});

onPosition

Type: function or undefined
Default: undefined

A position event listener that is called when the overlay is shown (before a showing effect starts), a window that contains the target is resized, and position method is called.
In the function, this refers to the current PlainOverlay instance.

This is used to adjust your custom face that depends on a layout of the overlay.

Properties

state

Type: number
Read-only

A number to indicate current state of the overlay.
It is one of the following static constant values:

  • PlainOverlay.STATE_HIDDEN (0): The overlay is being hiding fully.
  • PlainOverlay.STATE_SHOWING (1): A showing effect of the overlay is running.
  • PlainOverlay.STATE_SHOWN (2): The overlay is being showing fully.
  • PlainOverlay.STATE_HIDING (3): A hiding effect of the overlay is running.

For example:

toggleButton.addEventListener('click', function() {
  if (overlay.state === PlainOverlay.STATE_HIDDEN ||
      overlay.state === PlainOverlay.STATE_HIDING) {
    overlay.show();
  } else {
    overlay.hide();
  }
}, false);

style

Type: CSSStyleDeclaration
Read-only

A CSSStyleDeclaration object of the overlay to get or set the CSS properties.

For example:

overlay.style.backgroundImage = 'url(bg.png)';

blockingDisabled

Type: boolean
Default: false

By default, user operation such as scrolling, focusing and selecting text is blocked.
If you want, set true for this property to disable this behavior.

face

Get or set face option.

For example, change it while the overlay is shown:

overlay.show({
  face: progressBar,
  onShow: function() {
    setTimeout(function() {
      overlay.face = countDown;
    }, 3000);
  }
});

duration

Get or set duration option.

blur

Get or set blur option.

onShow, onHide, onBeforeShow, onBeforeHide, onPosition

Get or set onShow, onHide, onBeforeShow, onBeforeHide, and onPosition options.

PlainOverlay.show

overlay = PlainOverlay.show([target][, options])

This static method is a shorthand for:

(new PlainOverlay(target, options)).show()

See Also

  • PlainModal : The simple library for fully customizable modal window in a web page.

Thanks for images: arian.suresh, jxnblk/loading, The Pattern Library, tobiasahlin/SpinKit

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].