Skip to content

Commit

Permalink
export windowWidth and windowHeight from useKWindowDimensions
Browse files Browse the repository at this point in the history
  • Loading branch information
thanksameeelian committed Sep 29, 2023
1 parent 041b5e5 commit a3729f8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions lib/useKResponsiveWindow/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import { computed, onBeforeUnmount, onMounted, ref, watch } from '@vue/composition-api';
import useKWindowDimensions from '../useKWindowDimensions';
import useKWindowDimensions, { windowWidth, windowHeight } from '../useKWindowDimensions';
import MediaQuery from './MediaQuery';

/** Global variables */
const { windowWidth, windowHeight } = useKWindowDimensions();

/*
Implementing breakpoint controlled by watchers to work around
optimization issue: https://github.com/vuejs/vue/issues/10344
Expand Down Expand Up @@ -34,8 +32,10 @@ const heightQuery = new MediaQuery('screen and (max-height: 600px)', event => {
* Initialize media query window properties
*/
function initProps() {
orientationQuery.eventHandler(orientationQuery.mediaQueryList);
heightQuery.eventHandler(heightQuery.mediaQueryList);
if (window.matchMedia) {
orientationQuery.eventHandler(orientationQuery.mediaQueryList);
heightQuery.eventHandler(heightQuery.mediaQueryList);
}
}

initProps();
Expand Down
4 changes: 2 additions & 2 deletions lib/useKWindowDimensions.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import './composition-api'; //Due to @vue/composition-api shortcomings, add plug
import { onMounted, onUnmounted, ref } from '@vue/composition-api';

/** Global variables */
const windowWidth = ref(null);
const windowHeight = ref(null);
export const windowWidth = ref(null);
export const windowHeight = ref(null);
const isListenerAdded = ref(false);
const usageCount = ref(0);

Expand Down

0 comments on commit a3729f8

Please sign in to comment.