WickyNilliams / enquire.js

Awesome Media Queries in JavaScript
http://wicky.nillia.ms/enquire.js/
MIT License
3.62k stars 269 forks source link

How to enable enquire.js for a drupal project #174

Open webmasterpf opened 4 years ago

webmasterpf commented 4 years ago

Hi,

I've installed enquire .js in my project with:

$ npm install enquire.js
+ enquire.js@2.1.6

but nothing happen, so I would to know how to enable enquire.js for a drupal project ?

In Drupal8 there is many files that manage JS, I think libraries.yml could be the good one, but I can put the import command in a js file as well.

Is this the right command ? import enquire from "enquire.js";

To test it I done this:

  jQuery(document).ready(function () {
    ////***** ENQUIRE.JS ****/////
    var desktop = "screen and (min-width:1200px)";// sortie=>> min-width: XXXpx xlarge 1200px
    var desktopwide = "screen and (min-width:1440px) and (min-resolution:1dppx)";
    //Utilisation d'enquire.js
    enquire.register(desktop, {
        match : function() {
        console.log('Enquire.js : BP pour:'desktop);
        //Video sur HP
        /*$(".acces_rubriques iframe").each(function () {
            $(this).removeAttr('width');
            $(this).removeAttr('height');
            $(this).removeAttr('align');
        });*/
        $(".acces_rubriques iframe").height('95vh').width('60vw');//Video Gde Taille HP
        },
        unmatch : function() {
            example.unmatch();
        }
    });//enquire.register(desktop)
  });//Fin document.ready

Thanks for help