Skip to content

Commit

Permalink
performance tweak
Browse files Browse the repository at this point in the history
  • Loading branch information
razorness committed Aug 26, 2021
1 parent 4641f3e commit fc77f31
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vue-maplibre-gl",
"version": "1.0.0-beta.16",
"version": "1.0.0-beta.17",
"description": "Vue 3 plugin for maplibre-gl",
"keywords": [
"vue",
Expand Down
4 changes: 2 additions & 2 deletions src/components/map.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { defineComponent, getCurrentInstance, h, onBeforeUnmount, onMounted, PropType, provide, ref, shallowRef, unref, watch } from 'vue';
import { defineComponent, getCurrentInstance, h, markRaw, onBeforeUnmount, onMounted, PropType, provide, ref, shallowRef, unref, watch } from 'vue';
import { FitBoundsOptions, LngLatBoundsLike, LngLatLike, Map as MaplibreMap, MapboxOptions, Style, TransformRequestFunction } from 'maplibre-gl';
import { componentIdSymbol, emitterSymbol, isLoadedSymbol, mapSymbol, MglEvents, sourceIdSymbol } from '@/components/types';
import { defaults } from '@/components/defaults';
Expand Down Expand Up @@ -124,7 +124,7 @@ export default defineComponent({

// init map
// @ts-ignore
map.value = new MaplibreMap(opts);
map.value = markRaw(new MaplibreMap(opts));
registryItem.map = map.value;
isInitialized.value = true;
boundMapEvents.set('__load', () => (isLoaded.value = true, registryItem.isLoaded = true));
Expand Down
6 changes: 3 additions & 3 deletions src/components/mapRegistry.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { MglMap } from '@/components/index';
import maplibregl from 'maplibre-gl';
import { reactive } from 'vue';
import { markRaw, reactive } from 'vue';

export interface MapInstance {
component?: InstanceType<typeof MglMap>;
Expand Down Expand Up @@ -30,8 +30,8 @@ export function registerMap(instance: InstanceType<typeof MglMap>, key: symbol |
}
component.isLoaded = false;
component.isMounted = false;
component.component = instance;
component.map = instance.map as maplibregl.Map;
component.component = markRaw(instance);
component.map = markRaw(instance.map as maplibregl.Map);
component.isLoaded = (instance.map as maplibregl.Map)?.loaded() || false;

return component;
Expand Down

0 comments on commit fc77f31

Please sign in to comment.