videoPlayState.js 793 B

12345678910111213141516171819202122232425262728
  1. /* eslint-disable
  2. max-len,
  3. no-undef,
  4. */
  5. // TODO: This file was created by bulk-decaffeinate.
  6. // Fix any style issues and re-enable lint.
  7. /*
  8. * decaffeinate suggestions:
  9. * DS102: Remove unnecessary code created because of implicit returns
  10. * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
  11. */
  12. define(['base'], App =>
  13. App.directive('videoPlayState', $parse => ({
  14. restrict: 'A',
  15. link(scope, element, attrs) {
  16. const videoDOMEl = element[0]
  17. return scope.$watch(() => $parse(attrs.videoPlayState)(scope), function(
  18. shouldPlay
  19. ) {
  20. if (shouldPlay) {
  21. videoDOMEl.currentTime = 0
  22. return videoDOMEl.play()
  23. } else {
  24. return videoDOMEl.pause()
  25. }
  26. })
  27. }
  28. })))