The plugin does not get set up right and should be improved. I have been put on as co maintainer and will put the patch on if someone can hammer it out.

Spinoff issue from #2324691: plugin not detected (7.x) which covers 7.x .

A year ago I sorted out: on D8 the library paths should be:
/libraries/headroomjs/dist/headroom.min.js
/libraries/headroomjs/dist/jQuery.headroom.min.js

The other files are not required. in fact only the minified one is required.

W0lf recently asked:

Have there been any further updates to this? I renamed the paths for headroom.js/src/Headroom.js and headroom.js/src/jQuery.headroom.js to headroomjs/dist/headroom.min.js and headroomjs/dist/jQuery.headroom.min.js, respectively. This allowed the module to install as it apparently detected the correct files in the correct locations, but I still can't see any classes during scrolling added after enabling the module and headroom.js at /admin/config/user-interface/headroomjs.

Am I still missing something? Thanks!

Comments

HongPong created an issue. See original summary.

hongpong’s picture

the problem now is that the minified dist directory is not included. will submit a patch to use the expanded one.

hongpong’s picture

Priority: Normal » Major
Status: Active » Needs review
StatusFileSize
new3.17 KB

I futzed with the requirements strings, now it should give the right message for all four states (either missing file, both or none). Would request people look at this, as the module is broken.

hongpong’s picture

noticed that the attribute is missing on the modules page to give you a gear link to config as well.

hongpong’s picture

Status: Needs review » Needs work

No, the headroom.js from /src doesn't work. the one from here does work, which is packaged at https://unpkg.com/headroom.js

Will ponder the best way to handle this. hmmm....

w01f’s picture

Thanks so much for your work on this! I tried replacing the code you listed there, but it still doesn't work so I think I'm still naming something incorrectly or missed something to rename or maybe I need to uninstall and reinstall and then rename...anyway, looking forward to this cool module so thanks again for your efforts! =]

hongpong’s picture

Hi w0lf. I got it working earlier on the other environment - will drop what i think is the right patch here tomorrow. you'll use the "patch -v " command as described here https://www.drupal.org/project/headroomjs/git-instructions . To be specific here the 'install' command just checks if the files are in the places named, it doesn't do anything fancy on install (the only other thing it does is set the configuration fields).

hongpong’s picture

Status: Needs work » Needs review
StatusFileSize
new7.81 KB

Hi w0lf this should fix everything. I rewrote the readme and error messages, changed the path for the main script . and added a config 'gear' link to the modules page.

3 things: apply the patch using 'git patch -v' .
2. you have to get the headroom.js file from unpkg.com
3. there is an enable toggle on the config page that must be toggled to true, first checkbox.

If this works for you we can tag a beta2 release today. It should be solid all around.

w01f’s picture

Status: Needs review » Reviewed & tested by the community

Seems like it works great now! Only suggestion would be to possibly lower the default? I've set mine to about 15-20 for the desired effect on my site and working example - www.kobejet.com. Thanks again to Dan for working on this project and getting it ready for primetime!

  • HongPong authored 6bfb75a on 8.x-1.x
    Issue #2912809 by HongPong: Plugin not detected (8.x)
    
hongpong’s picture

Status: Reviewed & tested by the community » Fixed

Thanks for working through this with me w0lf.

Also this commit has a code smell fix the IDE flagged, in the js file:

if (typeof drupalSettings.headroomjs !== 'undefined' && $(drupalSettings.headroomjs.selector).length !== 0) {

the comparator was != which can cause an implicit type cast that we don't want. For related see:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Equality_compari...
https://stackoverflow.com/questions/16204840/javascript-comparing-to-nul...

Since the last build is broken due to the path changes this should be tagged beta2 - documentation and metadata updates from the patch above were committed on a separate issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.