Comments (9)
We're talking now of maybe doing this sooner rather than later. Will report back later this week with thoughts.
from modaal.
Any progress on this?
from modaal.
Hi @medikoo
Thanks for opening the conversation, it's certainly something we've thought about. At this time however, this is the library we chose to build on top of. We agree that there is value in not having a dependency and we will consider it down the line for expansion of the plugin.
from modaal.
Moving these examples here from #29 since I closed it.
e.g.
var dom = document.body;
var element = document.querySelector('.class-name|#id');
if(element.classList.contains('class-name') {};
element.addEventListener('click|keydown', function);
etc.
from modaal.
Yeah at first glance I thought this would be straight forward too, but we are using jQuery for more than just fancy DOM selectors and things. Yesterday I got as far as compiling a list of all the jQuery methods we use, so can look at what it would take to replace them all.
As you can see there are quite a lot of calls. So the question is where do we draw the line between implementing a lot of basic methods (adding weight to Modaal even when jQuery is present), versus depending on a library?
I would like to take a look at other UI/widget libraries (things like Isotope or even other modals), and see how they've handled this.
For replacing animate(), I can imagine having a sort of progressive enhancement. So if you have included a library that provides the animate API, such as jQuery or Velocity.js, we use it, otherwise we skip the animation and jump to the end result. E.g. an element might show or hide instantly rather than fading. Just an idea.
I'm sure we're not the first to have this discussion, so please feel free to share anything you know of that's relevant. :)
The list:
Handy selectors and DOM traversal:
$()
element.children()
element.contains()
element.find()
element.is()
DOM manipulation:
element.addClass()
element.append()
element.attr() and element.getAttribute() (why both?)
element.clone()
element.css()
element.data()
element.empty()
element.hasClass()
element.hide()
element.html()
element.on() - bind event
element.off() - unbind event
element.removeAttr()
element.removeClass()
Animation:
element.animate() - only used to fade opacity and call oncomplete() callback
element.stop()
AJAX:
$.ajax() (.success(), .error() and .abort() callbacks)
Misc:
array.extend() (options array, etc)
from modaal.
You could use Zepto, which has the same API, but much smaller file size. If you'd like to go vanilla JS (I recommend, because jQuery is an unnecessary abstraction today), You Might Not Need jQuery is a good resource. Here is some stuff I found as a response to your list:
Selectors and DOM traversal
$()
The dollar does a lot of things. If you're using it for selecting, use these:
document.querySelector(selector)
document.querySelectorAll(selector)
$el.children()
Vanilla: el.children
However, note that document.querySelectorAll
returns a NodeList, .children
returns a HTMLCollection etc. None of these can be looped through directly because they are not arrays, they are array-like. You can transform them into arrays using Array.from()
.
$el.contains($child)
Vanilla: el !== child && el.contains(child)
$el.find(selector)
Vanilla: el.querySelector(selector)
/el.querySelectorAll(selector)
$el.is($otherEl)
Vanilla: el === otherEl
DOM manipulation
$el.addClass()
/$el.removeClass()
For all classy stuff use classie for IE8+ or these for IE10+:
el.classList.add()
el.classList.remove()
$el.append()
Vanilla: el.appendChild()
$el.attr()
/$el.removeAttribute()
Vanilla:
el.getAttribute(attr)
el.setAttribute(attr, value)
el.removeAttribute()
$el.clone()
Vanilla: el.cloneNode(true)
$el.css('background', 'blue')
Vanilla: el.style.background = 'blue'
$el.data()
Vanilla: ?
$el.empty()
Vanilla: el.innerHTML = ''
$el.hide()
Vanilla: el.style.display = 'none'
$el.html()
Vanilla: el.innerHTML
$el.on()
/$el.off()
For all eventy stuff use eventie for IE8+ or these for IE9+:
el.addEventListener()
el.removeEventListener()
AJAX
Maybe it's a good idea to use the Fetch API if IE10+ is acceptable. Otherwise you could find a tiny AJAX library on Microjs.
from modaal.
Hi @silvenon, thanks for putting that together. I'll have a good read and try to get some time on this late next week.
from modaal.
What's the status on this? Or is this project dead?
from modaal.
hi @kareljan - project is technically not dead, this github may seem very quite but it is a tool we still use nearly daily. The difficulty has been dedicating time to it and work through both updates, and bugs as other, billable, projects unfortunately take some priority.
This particular task is something that is definitely on our minds with the plugin, though I can't provide any more detail than that, ora timeframe on when it may be looked at.
Thanks for your patience.
from modaal.
Related Issues (20)
- Change of source image within content-source conflict HOT 2
- Focus management (focus trap) HOT 1
- Option to loop through the gallery
- How To: Inserting modal content further up the page HOT 3
- Back tab focus not working
- Opening a image gallery from multiple sources
- How to open modal not user button? HOT 5
- How to close the modal?? HOT 1
- Question: is it possible to somehow autoplay the gallery images, so that no user interactive is needed?
- Close button first focusable element.
- Multiple instances of modaal issue HOT 3
- Getting clicked element's attributes HOT 9
- Modaal window background color
- should_open option doesn't work as data attribute
- Support ES6 loading
- Modal content outside ARIA landmark HOT 2
- How can I make this work with keyboard shortcuts.
- Animation options
- How to close in iframe/ajax?
- MP4 video not start in Mac Safari
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from modaal.