binders.js 890 B

123456789101112131415161718192021222324252627282930313233343536
  1. rivets.binders['src-strict'] = function(el, value) {
  2. var img = new Image()
  3. img.onload = function() {
  4. $(el).attr('src', value)
  5. }
  6. img.src = value
  7. }
  8. rivets.binders['transition'] = function(el, display) {
  9. if (display) {
  10. el.classList.remove('hide');
  11. setTimeout(function() {
  12. el.classList.add('show');
  13. }, 0);
  14. } else {
  15. el.classList.remove('show');
  16. setTimeout(function() {
  17. el.classList.add('hide');
  18. }, 200);
  19. }
  20. }
  21. rivets.binders['selected-section'] = function (el, sectionState) {
  22. var section = el.text;
  23. if (sectionState[section]) {
  24. el.classList.add('selected');
  25. } else {
  26. el.classList.remove('selected');
  27. }
  28. }
  29. rivets.binders['cloak'] = function (el) {
  30. setTimeout(function() {
  31. el.style.opacity = 1;
  32. }, 200);
  33. }