Fast configurator for sharing to facebook, vkontakte, ok.ru, twitter + YA.metrika support
RU and EN description + JSDoc also available in share.js file
- Add/import share.js file to your project
- Create new instance:
let share = new Share({/* options */});
- Use
.create
and.open
methods
Name | Type | Description | Default |
---|---|---|---|
url | String | url to share | |
title | String | site title | |
image | String | image url | |
description | String | site description | |
metrics | Object | yandex metrics object (?) | |
prefix | String | prefix for metrics goal | 'share_' |
width | Number | popup width | 600 |
height | Number | popup height | 600 |
isCanvas | Boolean | Set to true, if your game (based on canvas) can't open links | false |
mode | String | '_blank' or '', also can take any windowName value | '' |
library | String | Read below | 'vanilla' |
id | Number | if 'vanilla' choosen, pass metrics id |
vanilla, vue, react
vk, fb, tw, ok
You can use it to generate raw link as string w/o opening and metrics call
Example: Share.create('vk')
Use it to generate link, open new window for share and call metrics.
Metrics works only if metrics
option is passed
Example: Share.open('vk')
You can use script in vanilla js, react, vue, etc.
- Set 'vanilla' mode
- Pass
ym
tometrics
- Function:
this.metrics(thid.id,'reachGoal',`${this.prefix}${name}`)
- Set 'vue' mode
- Pass
this.$metrika
tometrics
- Function:
this.metrics.reachGoal(`${this.prefix}${name}`)
- Set 'react' mode
- Pass
ym
(your variable fromimport ym from 'react-yandex-metrika';
) tometrics
- Function:
this.metrics('reachGoal','${this.prefix}${name}')