Code Monkey home page Code Monkey logo

togglific's Introduction

Build Status npm version

Togglific

Enjoy a distraction-free web experience!

Toggle web animations on or off; for people with vestibular disorders, who are prone to motion sickness, or who find animations distracting!

Features

The following animated elements will paused on button click:

  • CSS Animations (animation and transform properties)
  • JavaScript Animations (requestAnimationFrame() method)
  • SVG animations
  • jQuery animations
  • Animated .gif and .webp images
  • HTML <video> elements
  • Targets same-domain <iframe> elements for all of the above

Demo

Check out the demo section to see Togglific in action!


Products

Togglific generates three separate products:

  1. Stand-alone script: For development teams to implement into their own projects and setup custom controls. This covers all animations.

    See the script options for more details on how to customize for your own needs!

  2. Bookmarklet: For anyone wishing to quickly pause animations on the current page their viewing.

    The bookmarklet also covers all animations and has the greatest browser support.

    Note: State does not persist; the user needs to click the bookmarklet control on each page load to pause animations.

  3. Browser extension: Available for Chrome and Firefox.

    With this, localStorage is used to persist the selection. The user only has to click the button once to always disable animations for the current domain.

    Note: At this time, the extension does not toggle JavaScript based animations due to technical limitations.

Let's look at each in more detail:

Stand-alone script

Usage

  1. Include the lib at the bottom of your page:
<script src="dist/stand-alone/togglific.js"></script>
  1. Create a new instance and supply the id of your toggle button:
<script>
  new Togglific.Togglific([options], 'toggler');
</script>

See script options for more info on the [options] parameter.

  1. Add the toggle button to your HTML:
<button id="toggler">Toggle Animations!</button>

npm Package

You can also grab the stand-alone script and include it into your project via npm!

Installation
npm install togglific
Usage
  1. In your JavaScript file…
const toggler = require('togglific');
// …
new toggler.Togglific([options], 'toggler');
  1. Then add a <button> element as a toggle.
<button id="toggler">Toggle Animations!</button>

Bookmarklet

Simply drag the Bookmarklet! link to your bookmarks bar in your browser and you're all set!

Browser extensions

Install the browser extension from one the following browser vendor plugin repositories!

Chrome

Install the browser extension from the Chrome Web Store!

Firefox

Install the browser extension from Firefox Add-ons!

Edge

Install the browser extension from the Microsoft Store!

Coming soon!


Script Options

The stand-alone script accepts options when using the script on your page or website.

Options are sent in the format of an object literal to the Togglific instance as the first parameter.

There are a few things you can set for options, including:

Custom CSS

If you want to customize, you can pass specific CSS to the object. By default, this CSS would be applied to all elements:

new Togglific.Togglific(
  {
    css: {
      height: 'auto',
      padding: '10px'
    }
  },
  'toggler'
);

Specify your own selectors

If you want only specific elements to be effected, you can add CSS selectors as a string:

new Togglific.Togglific(
  {
    selectors: 'section, .content'
  },
  'toggler'
);

Combine both options, Custom CSS and Specify your own Selectors to have specific elements only be effected with the desired CSS.

Exclude modules

By default, all components are included for toggling animations. If you'd prefer to remove a specific component to always allow animations, you can set it to be excluded.

For example, to exempt CSS and jQuery:

new Togglific.Togglific(
  {
    modules: {
      css: false,
      jquery: false
    }
  },
  'toggler'
);

Default options

To leave everything as-is and accept all components, set the instance [options] parameter to null.

new Togglific.Togglific(null, 'toggler');

Contributing

Contributions are always welcome! Please read the Contributing document if you'd like to help out with the project.

License

This project and its source code is licensed under the MIT license.

togglific's People

Contributors

svinkle avatar

Stargazers

Murray Inman avatar Zakaria Beji avatar Chinmay avatar realAzazello avatar  avatar  avatar  avatar  avatar Danny de Vries avatar Melanie Sumner avatar Riccardo Erra avatar Robert DeLuca avatar Barnabas Toth avatar Rozario Chivers avatar Harrison Powers avatar  avatar Matthew Tylee Atkinson avatar Marcus Herrmann avatar hh avatar Manuel Matuzovic avatar

Watchers

Rozario Chivers avatar James Cloos avatar

Forkers

fardarter

togglific's Issues

Togglific does not stop animation of animated GIF disguised as.jpg

Hi Scott. Thanks a lot for Togglific!

On some website, an animated image refused to stop. Opening it exclusively in a new browser tab, I saw it had the extension .jpg. I never ever had heard of animated Jpegs so far

animated jpg

so I downloaded it, and after inspecting it with XnViewMP, saw that in real it's a (animated) GIF which someone disguised as a jpg, maybe because the side would otherwise detect animated GIFs, and he might also want to dodge tools like Togglific..

FYI, Toggle Animated Gif CAN stop animation on above image!

So maybe you can extend Togglific to also work on .jpg/ .jpef files for said reason?

Cannot remove keyboard shortcut in Vivaldi

(It's possible this may be a Vivaldi bug. I haven't tested in other Chromium-based browsers, but they don't suit my needs as well as Vivaldi, so I won't be switching browser :)

To reproduce:

  • In Vivaldi, navigate to vivaldi://extensions.
  • Expand the hamburger menu and click Keyboard Shortcuts.
  • Scroll down to the entry for Togglific.
  • Click the Edit button.
  • Press Delete to clear the field.
  • Click outside the field.

The field now shows as there being no keyboard shortcut. But if you reload the page, the keyboard shortcut is still set.

This doesn't happen with other extensions; I can clear the keyboard shortcuts for Bitwarden, for example, and that change persists.

Please could you make it possible to remove the keyboard shortcut (or maybe even don't set one by default — there are only so many keyboard combinations available, after all, and people may already be using whatever you choose as the default).

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.