GithubHelp home page GithubHelp logo

gorkdesign / module-theme_breakpoints_js Goto Github PK

View Code? Open in Web Editor NEW

This project forked from burdamagazinorg/module-theme_breakpoints_js

0.0 1.0 0.0 19 KB

License: GNU General Public License v2.0

JavaScript 37.93% PHP 62.07%

module-theme_breakpoints_js's Introduction

Theme Breakpoints for Javascript

This module exposes theme-related breakpoints as directly usable Javascript variables.

Usage

When developing client-side Javascript applications, you might need to know about the breakpoints your currently used theme defines. Themes can define breakpoints this way, but they're not exposed automatically for client-side behaviors.

This module helps frontend developers by exposing the breakpoints as Javascript variables, being directly accessible via window.themeBreakpoints.

The function themeBreakpoints.getCurrentBreakpoint() tells you the currently matching breakpoint for the given client.

A new event themeBreakpoint:changed is being provided, which fires when the matching breakpoint of the client has changed. With this event, you're able to implement responsive Javascript behaviors via event listeners. Example event listener with JQuery: $(window).on('themeBreakpoint:changed', function (event, breakpoint) { alert('The current breakpoint has been changed to ' + breakpoint.name); });

Backend developers can use the theme_breakpoints_js service for conveniently receiving breakpoints defined by themes. It already takes care about defined breakpoints by base themes and also loads them in case a theme doesn't define breakpoints by itself.

Installation

  • This module obviously depends on Drupal core's breakpoint module.
  • Install this module as usual.
  • No configuration required. Once enabled, the currently used theme's breakpoints are available as JS variables.

module-theme_breakpoints_js's People

Contributors

tjwelde avatar alamowo avatar

Watchers

James Cloos 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.