Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Commit

Permalink
Fix zoom support with preload script
Browse files Browse the repository at this point in the history
  • Loading branch information
bbondy committed Dec 4, 2015
1 parent febc13a commit 66829d0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
11 changes: 5 additions & 6 deletions js/lib/webviewPreload.js → app/content/webviewPreload.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,25 @@
var electron = require('electron')
var ipc = electron.ipcRenderer
var webFrame = electron.webFrame
var webFrame = require('electron').webFrame
var ipc = require('electron').ipcRenderer

var browserZoomLevel = 0
var browserMaxZoom = 9
var browserMinZoom = -8

ipc.on('zoomIn', function () {
ipc.on('zoom-in', function () {
if (browserMaxZoom > browserZoomLevel) {
browserZoomLevel += 1
}
webFrame.setZoomLevel(browserZoomLevel)
})

ipc.on('zoomOut', function () {
ipc.on('zoom-out', function () {
if (browserMinZoom < browserZoomLevel) {
browserZoomLevel -= 1
}
webFrame.setZoomLevel(browserZoomLevel)
})

ipc.on('zoomReset', function () {
ipc.on('zoom-reset', function () {
browserZoomLevel = 0
webFrame.setZoomLevel(browserZoomLevel)
})
2 changes: 1 addition & 1 deletion js/components/frame.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ class Frame extends ImmutableComponent {
<webview
ref='webview'
src={this.props.frame.get('location')}
preload='./../lib/webviewPreload.js'/>
preload='content/webviewPreload.js'/>
</div>
}
}
Expand Down

2 comments on commit 66829d0

@bbondy
Copy link
Member Author

@bbondy bbondy commented on 66829d0 Dec 4, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aekeus please audit just this request. Merging.

@aekeus
Copy link
Member

@aekeus aekeus commented on 66829d0 Dec 4, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

++ tested in the browser

Please sign in to comment.