WhatSock / apex

Apex 4X: The Comprehensive ARIA Development Suite
MIT License
28 stars 10 forks source link

Error checking window.device in Slider.js #62

Closed lukos closed 3 months ago

lukos commented 3 months ago

Slider.js has code which queries window.device.type, which is undefined on my desktop Chrome so it errors in the console. I'm not sure whether this breaks anything other than the code inside the if statement but presumably easy enough to check typeof(window.device) !== "undefined" before checking for the device type?

Again, happy to do a PR if you are happy with the proposed change.

lukos commented 3 months ago

Actually, I do think it breaks my loop which fails as soon as the first slider is setup, meaning the remaining sliders are not wired up at all!

accdc commented 3 months ago

Hi, actually this is happening because the Slider.js module requires 2 dependencies.

If you navigate to where the modules are saved in the repo, 4X/Modules and open Slider.js, you will see "Required dependencies: CurrentDevice.js, Dragdealer.js"

These are listed in the order they need to be loaded.

I don't recommend removing that from the Slider code since it makes a difference for cross-device support.

lukos commented 3 months ago

Is this something that could be added to the online docs? Again, happy to make a PR.

accdc commented 3 months ago

Yes of course, it can certainly be added to the online docs.

I appreciate the PR offer, but it might be faster for me to do it since I know where everything connects, and if I add this in one place I need to add it everywhere.

By online docs, are you referring to the primary page for each widget type? E.G. https://whatsock.com/Templates/Sliders/

Can you think of anywhere else where this would be good to add?

Thanks again, Bryan

lukos commented 3 months ago

Hi Bryan, yes, that's where I was thinking of putting it, just a section that says, "Slider depends on....". I think this is helpful as well since i noticed there were a number of drag JS files in the distribution so it wouldn't otherwise be obvious which ones to use (unless I looked into the JS file like you suggested!).

accdc commented 3 months ago

No problem, I'll add a section for all the widgets and hopefully have this done by the end of this week. :)

accdc commented 3 months ago

Hi, I added the new required module data to all of the primary widget pages. You can see this within the JavaScript Syntax section. (This seemed the most logical place to put it.) The repo has been updated as with the live site.

I also did some markup maintenance and didn't realize my code prettifier has been broken for ages so everything got updated. I don't think I broke anything, but please let me know if anything looks or acts weird.

accdc commented 3 months ago

Closing this issue as completed.