videoPlayState.js 892 B

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