Changeset 35954 for main


Ignore:
Timestamp:
2022-01-11T11:32:12+13:00 (2 years ago)
Author:
cstephen
Message:

Save magnifier settings to localStorage and hide magnifier when cursor leaves the image

Location:
main/trunk/model-interfaces-dev/atea/ocr/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/model-interfaces-dev/atea/ocr/src/components/OcrImageDisplay.vue

    r35805 r35954  
    146146            }, 100);
    147147        },
    148         magnifierZoom() {
     148        magnifierZoom(newValue) {
    149149            if (this.showThresholdedImage) {
    150150                this.updateMagnifier(this.$refs.thresholdedImage);
     
    153153                this.updateMagnifier(this.$refs.ocrImage);
    154154            }
    155         }
     155
     156            localStorage.setItem("magnifierZoom", newValue);
     157        },
     158        enableMagnifier(newValue) {
     159            localStorage.setItem("enableMagnifier", newValue);
     160        }
     161    },
     162    beforeMount() {
     163        this.enableMagnifier = localStorage.getItem("enableMagnifier") === "true";
    156164    },
    157165    mounted() {
     
    159167            this.updateMagnifier(this.$refs.ocrImage);
    160168        }, 100);
     169
     170        this.magnifierZoom = localStorage.getItem("magnifierZoom") ?? "1.5";
    161171    }
    162172}
     
    218228
    219229        .controls {
     230            opacity: 1;
     231        }
     232
     233        .magnifier {
    220234            opacity: 1;
    221235        }
     
    274288    cursor: none;
    275289    border-radius: 40%;
     290
     291    transition: opacity var(--transition-duration);
     292    opacity: 0;
    276293}
    277294</style>
  • main/trunk/model-interfaces-dev/atea/ocr/src/main.js

    r35743 r35954  
    33import App from "./App.vue";
    44import ToggleButton from "./components/ToggleButton.vue"
     5
     6// Polyfill localstorage with an in-memory solution for old browsers.
     7// Adapted from https://gist.github.com/juliocesar/926500#gistcomment-1620487
     8try {
     9    window.localStorage.setItem("test_localstorage_available", "1");
     10    window.localStorage.removeItem("test_localstorage_available");
     11}
     12catch (error) {
     13    window.localStorage = {
     14        _data: {},
     15        setItem: function (id, val) {
     16            this._data[id] = String(val);
     17        },
     18        getItem: function (id) {
     19            return Object.prototype.hasOwnProperty.call(this._data, id) ? this._data[id] : undefined;
     20        },
     21        removeItem: function (id) {
     22            return delete this._data[id];
     23        },
     24        clear: function () {
     25            this._data = {};
     26        }
     27    };
     28}
    529
    630const store = createStore({
Note: See TracChangeset for help on using the changeset viewer.