joseph / Monocle

A silky, tactile browser-based ebook JavaScript library.
http://monocle.inventivelabs.com.au
MIT License
743 stars 200 forks source link

Font Resizing in monocle #220

Open priti123 opened 10 years ago

priti123 commented 10 years ago

there are multiple chapters in my epubfile when i am resizing the font it allowing me to resize only to 1 chapter if i resize the font for another chapter there is no effect on font i am using font magnifier control to do this i have modified the method as below:

Monocle.Controls.Magnifier = function (reader) {

var API = { constructor: Monocle.Controls.Magnifier }
var k = API.constants = API.constructor;
var p = API.properties = {
    buttons: [],
    magnified: false
}

function initialize() {
    p.reader = reader;
}

function createControlElements(holder) {
    var btn = holder.dom.make('div', 'controls_magnifier_button');
    btn.smallA = btn.dom.append('span', 'controls_magnifier_a', { text: 'A' });
    btn.largeA = btn.dom.append('span', 'controls_magnifier_A', { text: 'A' });
    btn.smallA.title = 'Decrease Font';
    btn.largeA.title = 'Increase Font';
    p.buttons.push(btn);
    Monocle.Events.listenForTap(btn.largeA, increaseFontSize);
    Monocle.Events.listenForTap(btn.smallA, decreaseFontSize);
    return btn;
}

function increaseFontSize() {

    if (k.MAGNIFICATION >= 3) {

        p.buttons[0].largeA.style.opacity = 0.3;
        p.buttons[0].largeA.style.disabled = true;
    }
    else {

        k.MAGNIFICATION += 0.2;

        p.reader.formatting.setFontScale(k.MAGNIFICATION, true);
        p.buttons[0].smallA.style.opacity = 1;
        p.buttons[0].smallA.style.disabled = false;
    }
}

function decreaseFontSize() {

    if (k.MAGNIFICATION <= 0.8) {

        p.buttons[0].smallA.style.opacity = 0.3;
        p.buttons[0].smallA.style.disabled = true;
    }
    else {

        k.MAGNIFICATION -= 0.2;
        p.reader.formatting.setFontScale(k.MAGNIFICATION, true);
        p.buttons[0].largeA.style.opacity = 1;
        p.buttons[0].largeA.style.disabled = false;
    }
}

API.createControlElements = createControlElements;

initialize();

return API;

}

Monocle.Controls.Magnifier.MAGNIFICATION = 1.15;

Stephanvs commented 10 years ago

For me this was fixed by manually replacing the Monocle.Formatting section in the monocore.js with the contents of this commit 2bd5999495bd94d41269f4a1a019ac389c4f80bf