mirror of
https://github.com/danielsogl/awesome-cordova-plugins.git
synced 2025-01-20 01:22:52 +08:00
fix screenshot plugin - closes #169
This commit is contained in:
parent
5105b0a184
commit
e391f5fa39
@ -1,4 +1,5 @@
|
||||
import {Cordova, Plugin} from './plugin';
|
||||
declare var navigator: any;
|
||||
@Plugin({
|
||||
plugin: 'https://github.com/gitawego/cordova-screenshot.git',
|
||||
pluginRef: 'navigator.screenshot',
|
||||
@ -8,29 +9,52 @@ export class Screenshot {
|
||||
|
||||
/**
|
||||
* Takes screenshot and saves the image
|
||||
*
|
||||
*
|
||||
* @param {string} format. Format can take the value of either 'jpg' or 'png'
|
||||
* On ios, only 'jpg' format is supported
|
||||
* @param {number} quality. Determines the quality of the screenshot.
|
||||
* @param {number} quality. Determines the quality of the screenshot.
|
||||
* Default quality is set to 100.
|
||||
* @param {string} filename. Name of the file as stored on the storage
|
||||
* @param {string} filename. Name of the file as stored on the storage
|
||||
*/
|
||||
@Cordova({
|
||||
successIndex: 1,
|
||||
errorIndex: 0
|
||||
})
|
||||
static save (format?: string, quality?: number, filename?: string): Promise<any> {return; }
|
||||
static save (format?: string, quality?: number, filename?: string): Promise<any> {
|
||||
return new Promise<any>(
|
||||
(resolve, reject) => {
|
||||
navigator.screenshot.save(
|
||||
(error, result) => {
|
||||
if(error){
|
||||
reject(error);
|
||||
}else{
|
||||
resolve(result);
|
||||
}
|
||||
},
|
||||
format,
|
||||
quality,
|
||||
filename
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Takes screenshot and returns the image as an URI
|
||||
*
|
||||
* @param {number} quality. Determines the quality of the screenshot.
|
||||
*
|
||||
* @param {number} quality. Determines the quality of the screenshot.
|
||||
* Default quality is set to 100.
|
||||
*/
|
||||
|
||||
@Cordova({
|
||||
successIndex: 1,
|
||||
errorIndex: 0
|
||||
})
|
||||
static URI (quality?: number): Promise<any> {return; }
|
||||
}
|
||||
static URI (quality?: number): Promise<any> {
|
||||
return new Promise<any>(
|
||||
(resolve, reject) => {
|
||||
navigator.screenshot.URI(
|
||||
(error, result) => {
|
||||
if(error){
|
||||
reject(error);
|
||||
}else{
|
||||
resolve(result);
|
||||
}
|
||||
},
|
||||
quality
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user