# Magazine viewer using JavaScript

You can implement the magazine viewer as shown in our web demo by writing some custom code.

[Try for Free](https://www.nutrient.io/sdk/web/getting-started.md)

[Launch Demo](https://www.nutrient.io/demo/magazine-viewer)

Make the following customizations in Nutrient Web SDK:

- Disable continuous scroll and default to double-page mode.

- Move the main toolbar to the bottom.

- Hide the toolbar items that aren’t needed.

- Add a custom toolbar item that can be used to toggle the fullscreen view.

```js

// Disable continuous scroll and default to double-page mode.
const initialViewState = new NutrientViewer.ViewState({
	scrollMode: NutrientViewer.ScrollMode.PER_SPREAD,
	layoutMode: NutrientViewer.LayoutMode.DOUBLE,
	keepFirstSpreadAsSinglePage: true,
});

// A custom toolbar item to toggle fullscreen mode.
const fullScreenToolbarItem = {
	type: 'custom',
	title: 'Toggle full screen mode',
	onPress: () => {
		const container =
			typeof defaultConfiguration.container === 'string'? document.querySelector(defaultConfiguration.container).parentNode
				: defaultConfiguration.container.parentNode;

		// You can implement the fullscreen mode on your own. Either see our
		// functions below for information on how to activate it, or look at our guides:
		// https://www,nutrient.io/guides/web/features/fullscreen-mode/
		if (isFullscreenEnabled()) {
			exitFullscreen();
		} else {
			requestFullScreen(container);
		}
	},
};

// Only show the relevant toolbar items.
let toolbarItems = [
	{ type: 'sidebar-bookmarks', dropdownGroup: null },
	{ type: 'sidebar-thumbnails', dropdownGroup: null },
	{ type: 'highlighter' },
	{ type: 'zoom-in' },
	{ type: 'zoom-out' },
	{ type: 'spacer' },
	{ type: 'search' },
	fullScreenToolbarItem,
];

// Load Nutrient.
NutrientViewer.load({...defaultConfiguration,
	toolbarPlacement: NutrientViewer.ToolbarPlacement.BOTTOM,
	initialViewState,
	toolbarItems,
});

// All the functions written below are just utility functions used
// to toggle fullscreen mode.
function isFullscreenEnabled() {
	return (
		document.fullscreenElement ||
		document.mozFullScreenElement ||
		document.webkitFullscreenElement ||
		document.msFullscreenElement
	);
}

function isFullScreenSupported() {
	return (
		document.fullscreenEnabled ||
		document.mozFullScreenEnabled ||
		document.msFullScreenEnabled ||
		document.webkitFullscreenEnabled
	);
}

function requestFullScreen(element) {
	if (element.requestFullscreen) {
		element.requestFullscreen();
	} else if (element.mozRequestFullScreen) {
		element.mozRequestFullScreen();
	} else if (element.webkitRequestFullscreen) {
		element.webkitRequestFullscreen();
	} else if (element.msRequestFullscreen) {
		element.msRequestFullscreen();
	}
}

function exitFullscreen() {
	if (document.webkitExitFullscreen) {
		document.webkitExitFullscreen();
	} else if (document.mozCancelFullScreen) {
		document.mozCancelFullScreen();
	} else if (document.msExitFullscreen) {
		document.msExitFullscreen();
	} else if (document.exitFullscreen) {
		document.exitFullscreen();
	}
}

```

---

## Related pages

- [Fullscreen mode in our JavaScript PDF viewer](/guides/web/features/fullscreen-mode.md)
- [Customizing the presentation mode in our JavaScript viewer](/guides/web/viewer/viewing-options/presentation-mode.md)

