videoPlayState.js 786 B

1234567891011121314151617181920212223242526272829
  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', $parse => ({
  13. restrict: 'A',
  14. link(scope, element, attrs) {
  15. const videoDOMEl = element[0]
  16. return scope.$watch(
  17. () => $parse(attrs.videoPlayState)(scope),
  18. function (shouldPlay) {
  19. if (shouldPlay) {
  20. videoDOMEl.currentTime = 0
  21. return videoDOMEl.play()
  22. } else {
  23. return videoDOMEl.pause()
  24. }
  25. }
  26. )
  27. },
  28. }))