import "./BackTop.css";
/* script */
//
//
//
//
//
//
//
//
//
//
//
//
import { componentMixin, createComponentName } from '../_utils/component';
import quickItem from './QuickItem';
import icon from '../Icon';
const __vue_script__ = {
  name: createComponentName('quick-link-back-top'),
  components: {
    icon,
    quickItem
  },
  mixins: [componentMixin],

  data() {
    return {
      isShowBackTopBtn: false
    };
  },

  mounted() {
    window.addEventListener('scroll', this.handleScroll, false);
  },

  beforeDestroy() {
    window.removeEventListener('scroll', this.handleScroll, false);
  },

  methods: {
    scrollToTop() {
      this.lastTop = undefined;
      this.beginScrollToTop();
    },

    beginScrollToTop() {
      const c = document.documentElement.scrollTop || document.body.scrollTop;
      if (this.lastTop < c) return;
      this.lastTop = c;

      if (c > 20) {
        window.requestAnimationFrame(this.beginScrollToTop);
        window.scrollTo(0, c - c / 8);
      } else {
        window.scrollTo(0, 0);
      }
    },

    handleScroll() {
      this.isShowBackTopBtn = window.pageYOffset >= 100;
    }

  }
};
/* template */

var __vue_render__ = function () {
  var _vm = this;

  var _h = _vm.$createElement;

  var _c = _vm._self._c || _h;

  return _c("quick-item", {
    directives: [{
      name: "show",
      rawName: "v-show",
      value: _vm.isShowBackTopBtn,
      expression: "isShowBackTopBtn"
    }],
    class: _vm.bem(),
    nativeOn: {
      click: function ($event) {
        return _vm.scrollToTop($event);
      }
    }
  }, [_c("div", [_c("icon", {
    attrs: {
      name: "arrow-top"
    }
  }), _vm._v(" "), _c("span", {
    class: _vm.bem("tip")
  }, [_vm._v("回到"), _c("br"), _vm._v("顶部")])], 1)]);
};

var __vue_staticRenderFns__ = [];
__vue_render__._withStripped = true;
/* style */

const __vue_inject_styles__ = undefined;
/* scoped */

const __vue_scope_id__ = undefined;
/* module identifier */

const __vue_module_identifier__ = undefined;
/* functional template */

const __vue_is_functional_template__ = false;
/* component normalizer */

import __vue_normalize__ from '../_utils/vue-normalize-component.js';
/* style inject */

/* style inject SSR */

export default __vue_normalize__({
  render: __vue_render__,
  staticRenderFns: __vue_staticRenderFns__
}, __vue_inject_styles__, __vue_script__, __vue_scope_id__, __vue_is_functional_template__, __vue_module_identifier__, undefined, undefined);