anchor.js 449 B

1234567891011121314151617181920212223
  1. 'use strict'
  2. export default {
  3. state: {
  4. shown: false,
  5. hash: ''
  6. },
  7. getters: {},
  8. mutations: {
  9. anchorChange: (state, opts) => {
  10. state.shown = (opts.shown === true)
  11. state.hash = opts.hash || ''
  12. }
  13. },
  14. actions: {
  15. anchorOpen({ commit, dispatch }, hash) {
  16. commit('anchorChange', { shown: true, hash })
  17. },
  18. anchorClose({ commit, dispatch }) {
  19. commit('anchorChange', { shown: false })
  20. }
  21. }
  22. }